Skip to content
Snippets Groups Projects

Sip login

Merged Kali Kaneko requested to merge kali/bitmask-vpn:sip-login into libraries
7 unresolved threads

merge the sip authentication, and functional login dialogs (this will need more ux work tho).

Edited by Kali Kaneko

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
59 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)
  • meskio
    meskio @meskio started a thread on an outdated change in commit b9cae0b7
  • 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")
  • meskio
    meskio @meskio started a thread on commit b9cae0b7
  • 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()
  • meskio
    meskio @meskio started a thread on an outdated change in commit 70922083
  • 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))
  • meskio
    meskio @meskio started a thread on commit 70922083
  • 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.

    • mostly avoid reconnections to faraway places.

      we can ignore for now - this is being reworked on another branch.

    • Please register or sign in to reply
  • meskio
    meskio @meskio started a thread on commit 9882dfc4
  • 22 22 type anonymousAuthentication struct{}
    23 23
    24 24 func (a *anonymousAuthentication) needsCredentials() bool {
    25 return true
    25 return false
  • meskio
    meskio @meskio started a thread on commit 339a30fd
  • 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 }
  • Kali Kaneko added 1 commit

    added 1 commit

    • cda7f025 - [refactor] fix error handling after review

    Compare with previous version

  • added a commit addressing these comments

  • Please register or sign in to reply
    Loading