Documentation ¶
Index ¶
- Constants
- Variables
- func DeleteNodeByUserID(db *mgo.Session, id bson.ObjectId) error
- func DeleteShareByUserID(db *mgo.Session, id bson.ObjectId) error
- func DeleteUserByID(db *mgo.Session, id bson.ObjectId) error
- func Error(v ...interface{}) error
- func ErrorConvert(err error) error
- func Errorf(format string, v ...interface{}) error
- func LoadShareFromRemote(address string) ([]byte, error)
- func PasswordVerify(password, hashedPassword string) error
- func RemoveNodeFromShare(db *mgo.Session, userID, nodeID bson.ObjectId) error
- type ErrorBody
- type Node
- type NodeV2ray
- type Share
- type Token
- type User
Constants ¶
View Source
const ( VSub = "vsub" UserCollection = "user" NodeCollection = "node" )
View Source
const ( MiddwareKeyLogger = "Logger" MiddwareKeyMongodb = "Mongodb" MiddwareKeySession = "Session" MiddwareKeyUserID = "UserID" )
Variables ¶
View Source
var ErrIsExist = errors.New("Is exist.")
View Source
var RegexpPwd = regexp.MustCompile(`^[A-Za-z0-9]{1,64}$`)
RegexpPwd is regexp with sha256 password
View Source
var RegexpUser = regexp.MustCompile(`^[A-Za-z0-9.+-_@]{3,30}$`)
RegexpUser is regexp with username
Functions ¶
func ErrorConvert ¶
func LoadShareFromRemote ¶
func PasswordVerify ¶
PasswordVerify verify original password with bcrypt password
Types ¶
type ErrorBody ¶
func NewErrorBody ¶
type Node ¶
type NodeV2ray ¶
type NodeV2ray struct { Port string `json:"port" bson:"port"` Ps string `json:"ps" bson:"ps"` Tls string `json:"tls" bson:"tls"` ID string `json:"id" bson:"id"` Aid string `json:"aid" bson:"aid"` V string `json:"v" bson:"v"` Host string `json:"host" bson:"host"` Type string `json:"type" bson:"type"` Path string `json:"path" bson:"path"` Net string `json:"net" bson:"net"` Add string `json:"add" bson:"add"` }
func DecodeV2ray ¶
type Token ¶
type Token struct { // Base Version string `json:"version" bson:"version"` UserID string `json:"id" bson:"user_id"` Nonce string `json:"nonce" bson:"nonce"` Expiry time.Time `json:"expiry" bson:"expiry"` Hmac string `json:"hmac" bson:"hmac"` }
Token struct represents the secret token
func NewToken ¶
NewToken creates a new Token object from a User object and a secret. The user object must have ID field filled.
func ParseToken ¶
ParseToken parses the authencation string and returns a pointer to the result Token object. If the token is invalid in any way, the pointer will be nil and an error will be returned
type User ¶
type User struct { ID bson.ObjectId `json:"id" bson:"_id,omitempty"` UserName string `json:"username" bson:"username,omitempty"` Password string `json:"password,omitempty" bson:"-"` HashedPassword string `json:"-" bson:"hashed_password,omitempty"` Token string `json:"-" bson:"token,omitempty"` Expiry *time.Time `json:"-" bson:"expiry,omitempty"` }
func FindUserByID ¶
FindUserByID find a user exists by id
func FindUserByUserName ¶
FindUserByUserName find a user exists by username
func (*User) HashPassword ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.