-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
75 lines (63 loc) · 1.71 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package main
// managers
import (
_ "github.com/while-loop/remember-me/remme/manager/lastpass"
)
// webservices
import (
_ "github.com/while-loop/remember-me/remme/webservice/facebook"
)
import (
"context"
"fmt"
"time"
"github.com/sirupsen/logrus"
"github.com/while-loop/remember-me/remme"
"github.com/while-loop/remember-me/remme/api/services/v1/changer"
"github.com/while-loop/remember-me/remme/log"
"github.com/while-loop/remember-me/remme/manager"
"github.com/while-loop/remember-me/remme/storage/stub"
"github.com/while-loop/remember-me/remme/util"
"github.com/while-loop/remember-me/remme/webservice"
"google.golang.org/grpc"
)
func main() {
log.Logger.SetLevel(logrus.DebugLevel)
// Set up a connection to the server.
manStr, email, password := "lastpass", "", ""
local(manStr, email, password)
//grpcMode(email, password)
}
func local(manStr, email, password string) {
man, err := manager.GetManager(manStr, email, password)
if err != nil {
log.Fatalf("%s", err)
}
app := remme.NewApp(stub.New(), webservice.Services())
log.Info(man.GetSites())
jobId := app.ChangePasswords(man, util.DefaultPasswdFunc)
fmt.Println(jobId)
time.Sleep(5 * time.Second)
}
func grpcMode(email, password string) {
fmt.Println("setting client")
conn, err := grpc.Dial("localhost:8081", grpc.WithInsecure())
if err != nil {
log.Fatalf("did not connect: %v", err)
}
defer conn.Close()
c := changer.NewChangerClient(conn)
req := &changer.ChangeRequest{
Password: password,
Email: email,
Manager: changer.ChangeRequest_LASTPASS,
PasswdConfig: &changer.PasswdConfig{
Length: 8,
},
}
reply, err := c.ChangePassword(context.Background(), req)
if err != nil {
log.Fatal(err)
}
log.Debug(reply)
}