Sip login
merge the sip authentication, and functional login dialogs (this will need more ux work tho).
Merge request reports
Activity
changed milestone to %LibraryVPN-windows
assigned to @meskio
mentioned in issue #334 (closed)
mentioned in issue #333
added 13 commits
- c236dfcf - [feat] add sip authentication
- efdeba8e - [test] sip integration test
- 8bb41cff - [refactor] refactor auth files
- c56df012 - [feat] expose auth API in pkg/vpn
- 249a8844 - [bug] use the right http client to fetch the auth
- 60a35bdd - [pkg] add float-deployed demo libpvn for tests
- a10c5ecd - [feat] login feedback
- b9cae0b7 - [feat] cache authentication token
- 70922083 - [debug] improve error handling for geolocation
- 9882dfc4 - [bug] anon needs no credentials
- 30587fb2 - [feat] pick only the top 3 gateways
- 339a30fd - [feat] reset error
- 2f1f3523 - [feat] reset notification
Toggle commit list59 if err != nil { 60 return nil, err 61 } 62 writeToken(token) 63 return token, nil 64 } 65 66 func getTokenPath() string { 67 return path.Join(config.Path, config.ApplicationName+".token") 68 } 69 70 func writeToken(token []byte) { 71 tp := getTokenPath() 72 err := ioutil.WriteFile(tp, token, 0600) 73 if err != nil { 74 log.Println("BUG: cannot write token to", tp) changed this line in version 4 of the diff
66 func getTokenPath() string { 67 return path.Join(config.Path, config.ApplicationName+".token") 68 } 69 70 func writeToken(token []byte) { 71 tp := getTokenPath() 72 err := ioutil.WriteFile(tp, token, 0600) 73 if err != nil { 74 log.Println("BUG: cannot write token to", tp) 75 } 76 } 77 78 func readToken() ([]byte, error) { 79 f, err := os.Open(getTokenPath()) 80 if err != nil { 81 log.Println("Error: cannot open token file") changed this line in version 4 of the diff
84 token, err := ioutil.ReadAll(f) 85 if err != nil { 86 log.Println("Error: cannot read token") 87 return nil, err 88 } 89 return token, nil 90 } 91 92 func hasRecentToken() bool { 93 statinfo, err := os.Stat(getTokenPath()) 94 if err != nil { 95 return false 96 } 97 lastWrote := statinfo.ModTime().Unix() 98 /* in vpnweb we set the duration of the token to 24 hours */ 99 old := time.Now().Add(-time.Hour * 20).Unix() 235 237 resp, err := b.client.Post(config.GeolocationAPI, "", nil) 236 238 if err != nil { 237 return nil, err 239 client := &http.Client{} 240 _resp, err := client.Post(config.GeolocationAPI, "", nil) 241 if err != nil { 242 log.Println("ERROR: could not fetch geolocation:", fmt.Errorf("%s", err)) 243 return nil, err 244 } 245 resp = _resp 238 246 } 247 239 248 defer resp.Body.Close() 240 249 if resp.StatusCode != 200 { 241 return nil, fmt.Errorf("get geolocation failed with status: %s", resp.Status) 250 log.Println("ERROR: bad status code while fetching geolocation:", fmt.Errorf("%s", resp.Status)) changed this line in version 4 of the diff
221 222 } 222 223 } 223 224 } 224 eip.Gateways = gws 225 226 if len(gws) == 0 { 227 log.Println("ERROR: avoiding to replace eip.Gateways will null list. Is the geolocation service properly configured?") 228 } else { 229 if len(gws) > 2 { 230 eip.Gateways = gws[:3] 231 } else { 232 eip.Gateways = gws 233 } 234 log.Println("Picked best gateways for location:", eip.Gateways) What is the rationale here? Why do we only pick 3 gateways instead of trying all of them? Do we assume will never be three gateways failing at once close to each other and want the client to try to pick the closest one always?
I'm not sure what is best, maybe this is the right approach. As long that there is no more than 2 gws in the same colo I guess this will work fine.
6 6 #include "handlers.h" 7 7 #include "lib/libgoshim.h" 8 8 9 GoString toGoStr(QString s) 10 { 11 char *c = s.toLocal8Bit().data(); 12 return (GoString){c, (long int)strlen(c)}; 13 } I think I found a more correct way, in the commits in !107 (merged)