Skip to content

Commit

Permalink
format and vendor
Browse files Browse the repository at this point in the history
  • Loading branch information
林志宇 committed Mar 22, 2019
1 parent 2963076 commit 4ce0be3
Show file tree
Hide file tree
Showing 11 changed files with 886 additions and 21 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ require (
github.com/flynn/noise v0.0.0-20180327030543-2492fe189ae6
github.com/go-chi/chi v4.0.2+incompatible
github.com/google/uuid v1.1.1
github.com/gorilla/securecookie v1.1.1
github.com/gorilla/sessions v1.1.3 // indirect
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d
github.com/inconshreveable/mousetrap v1.0.0 // indirect
Expand Down
20 changes: 10 additions & 10 deletions pkg/manager/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ type Config struct {

// Node manages AppNodes.
type Node struct {
c Config
nodes map[cipher.PubKey]node.RPCClient // connected remote nodes.
users UserStorer
sessions *SessionsManager
mu *sync.RWMutex
c Config
nodes map[cipher.PubKey]node.RPCClient // connected remote nodes.
users UserStorer
sessions *SessionsManager
mu *sync.RWMutex
}

// NewNode creates a new Node.
Expand All @@ -49,11 +49,11 @@ func NewNode(config Config) (*Node, error) {
return nil, err
}
return &Node{
c: config,
nodes: make(map[cipher.PubKey]node.RPCClient),
users: users,
c: config,
nodes: make(map[cipher.PubKey]node.RPCClient),
users: users,
sessions: NewSessionsManager(users, config.Sessions),
mu: new(sync.RWMutex),
mu: new(sync.RWMutex),
}, nil
}

Expand Down Expand Up @@ -553,4 +553,4 @@ func catch(err error) {
if err != nil {
panic(err)
}
}
}
12 changes: 7 additions & 5 deletions pkg/manager/sessions.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ package manager
import (
"encoding/gob"
"errors"
"github.com/google/uuid"
"github.com/gorilla/securecookie"
"github.com/skycoin/skywire/internal/httputil"
"net/http"
"sync"
"time"

"github.com/google/uuid"
"github.com/gorilla/securecookie"

"github.com/skycoin/skywire/internal/httputil"
)

const (
Expand Down Expand Up @@ -134,7 +136,7 @@ func (s *SessionsManager) delSession(w http.ResponseWriter, r *http.Request) err
delete(s.sessions, sid)
s.mu.Unlock()
http.SetCookie(w, &http.Cookie{
Name: sessionCookieName,
Name: sessionCookieName,
Domain: s.config.Domain,
MaxAge: -1,
Secure: s.config.Secure,
Expand Down Expand Up @@ -166,4 +168,4 @@ func (s *SessionsManager) checkSession(r *http.Request) error {
return errors.New("invalid session") // TODO: proper error
}
return nil
}
}
14 changes: 8 additions & 6 deletions pkg/manager/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import (
"bytes"
"encoding/gob"
"errors"
"github.com/skycoin/skywire/pkg/cipher"
"go.etcd.io/bbolt"
"os"
"path/filepath"
"time"

"go.etcd.io/bbolt"

"github.com/skycoin/skywire/pkg/cipher"
)

const (
Expand Down Expand Up @@ -63,8 +65,8 @@ type UserStorer interface {
}

type UsersConfig struct {
DBPath string
SaltLen int // Salt Len for password verification data.
DBPath string
SaltLen int // Salt Len for password verification data.
UsernamePattern string // regular expression for usernames (no check if empty). TODO
PasswordPattern string // regular expression for passwords (no check of empty). TODO
}
Expand Down Expand Up @@ -109,9 +111,9 @@ func (s *BoltUserStore) NewUser(username, password string) bool {
}

func (s *BoltUserStore) DeleteUser(username string) {
catch(s.db.Update(func(tx *bbolt.Tx) error {
catch(s.db.Update(func(tx *bbolt.Tx) error {
return tx.Bucket([]byte(boltUserBucketName)).Delete([]byte(username))
}))
}))
}

func (s *BoltUserStore) HasUser(username string) bool {
Expand Down
19 changes: 19 additions & 0 deletions vendor/github.com/gorilla/securecookie/.travis.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions vendor/github.com/gorilla/securecookie/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

80 changes: 80 additions & 0 deletions vendor/github.com/gorilla/securecookie/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

61 changes: 61 additions & 0 deletions vendor/github.com/gorilla/securecookie/doc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions vendor/github.com/gorilla/securecookie/fuzz.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 4ce0be3

Please sign in to comment.