Documentation
¶
Index ¶
- Constants
- Variables
- func ValidateOauthType(oauthType string) error
- type AddressBook
- type AddressBookCollection
- type AddressBookCollectionList
- type AddressBookCollectionRule
- type AddressBookCollectionRuleList
- type AddressBookList
- type AuditConn
- type AuditConnList
- type AuditFile
- type AuditFileList
- type GithubUser
- type Group
- type GroupList
- type IdModel
- type LoginLog
- type LoginLogList
- type Oauth
- type OauthList
- type OauthUser
- type OauthUserBase
- type OidcUser
- type Pagination
- type Peer
- type PeerList
- type ServerCmd
- type ServerCmdList
- type ShareRecord
- type ShareRecordList
- type StatusCode
- type Tag
- type TagList
- type TimeModel
- type User
- type UserList
- type UserThird
- type UserToken
- type UserTokenList
- type Version
Constants ¶
View Source
const ()
View Source
const ()
View Source
const ( AuditActionNew = "new" AuditActionClose = "close" )
View Source
const ( GroupTypeDefault = 1 // 默认 )
View Source
const ( LoginLogClientWebAdmin = "webadmin" LoginLogClientWeb = "webclient" LoginLogClientApp = "app" )
View Source
const ( LoginLogTypeAccount = "account" LoginLogTypeOauth = "oauth" )
View Source
const ( IsDeletedNo = 0 IsDeletedYes = 1 )
View Source
const ( // make sure the value shouldbe lowercase OauthTypeGithub string = "github" OauthTypeGoogle string = "google" OauthTypeOidc string = "oidc" OauthTypeWebauth string = "webauth" PKCEMethodS256 string = "S256" PKCEMethodPlain string = "plain" )
View Source
const ( UserEndpointGithub string = "https://api.github.com/user" IssuerGoogle string = "https://accounts.google.com" )
View Source
const ( ServerCmdTargetIdServer = "21115" ServerCmdTargetRelayServer = "21117" )
View Source
const OIDC_DEFAULT_SCOPES = "openid,profile,email"
Variables ¶
View Source
var AdminRouteNames = []string{"*"}
View Source
var SysIdServerCmds = []*ServerCmd{ {Cmd: "h", Option: "", Explain: "show help", Target: ServerCmdTargetIdServer}, {Cmd: "relay-servers", Alias: "rs", Option: "<separated by ,>", Explain: "set or show relay servers", Target: ServerCmdTargetIdServer}, {Cmd: "ip-blocker", Alias: "ib", Option: "[<ip>|<number>] [-]", Explain: "block or unblock ip or show blocked ip", Target: ServerCmdTargetIdServer}, {Cmd: "ip-changes", Alias: "ic", Option: "[<id>|<number>] [-]", Explain: "ip-changes(ic) [<id>|<number>] [-]", Target: ServerCmdTargetIdServer}, {Cmd: "always-use-relay", Alias: "aur", Option: "[y|n]", Explain: "always use relay", Target: ServerCmdTargetIdServer}, {Cmd: "test-geo", Alias: "tg", Option: "<ip1> <ip2>", Explain: "test geo", Target: ServerCmdTargetIdServer}, }
View Source
var SysRelayServerCmds = []*ServerCmd{ {Cmd: "h", Option: "", Explain: "show help", Target: ServerCmdTargetRelayServer}, {Cmd: "blacklist-add", Alias: "ba", Option: "<ip>", Explain: "blacklist-add(ba) <ip>", Target: ServerCmdTargetRelayServer}, {Cmd: "blacklist-remove", Alias: "br", Option: "<ip>", Explain: "blacklist-remove(br) <ip>", Target: ServerCmdTargetRelayServer}, {Cmd: "blacklist", Alias: "b", Option: "<ip>", Explain: "blacklist(b) <ip>", Target: ServerCmdTargetRelayServer}, {Cmd: "blocklist-add", Alias: "Ba", Option: "<ip>", Explain: "blocklist-add(Ba) <ip>", Target: ServerCmdTargetRelayServer}, {Cmd: "blocklist-remove", Alias: "Br", Option: "<ip>", Explain: "blocklist-remove(Br) <ip>", Target: ServerCmdTargetRelayServer}, {Cmd: "blocklist", Alias: "B", Option: "<ip>", Explain: "blocklist(B) <ip>", Target: ServerCmdTargetRelayServer}, {Cmd: "downgrade-threshold", Alias: "dt", Option: "[value]", Explain: "downgrade-threshold(dt) [value]", Target: ServerCmdTargetRelayServer}, {Cmd: "downgrade-start-check", Alias: "t", Option: "[value(second)]", Explain: "downgrade-start-check(t) [value(second)]", Target: ServerCmdTargetRelayServer}, {Cmd: "limit-speed", Alias: "ls", Option: "[value(Mb/s)]", Explain: "limit-speed(ls) [value(Mb/s)]", Target: ServerCmdTargetRelayServer}, {Cmd: "total-bandwidth", Alias: "tb", Option: "[value(Mb/s)]", Explain: "total-bandwidth(tb) [value(Mb/s)]", Target: ServerCmdTargetRelayServer}, {Cmd: "single-bandwidth", Alias: "sb", Option: "[value(Mb/s)]", Explain: "single-bandwidth(sb) [value(Mb/s)]", Target: ServerCmdTargetRelayServer}, {Cmd: "usage", Alias: "u", Option: "", Explain: "usage(u)", Target: ServerCmdTargetRelayServer}, }
View Source
var UserRouteNames = []string{
"MyTagList", "MyAddressBookList", "MyInfo", "MyAddressBookCollection", "MyPeer", "MyShareRecordList", "MyLoginLog",
}
Functions ¶
Types ¶
type AddressBook ¶
type AddressBook struct { RowId uint `gorm:"primaryKey" json:"row_id"` Id string `json:"id" gorm:"default:0;not null;index"` Username string `json:"username" gorm:"default:'';not null;"` Password string `json:"password" gorm:"default:'';not null;"` Hostname string `json:"hostname" gorm:"default:'';not null;"` Alias string `json:"alias" gorm:"default:'';not null;"` Platform string `json:"platform" gorm:"default:'';not null;"` Tags custom_types.AutoJson `json:"tags" gorm:"not null;" swaggertype:"array,string"` Hash string `json:"hash" gorm:"default:'';not null;"` UserId uint `json:"user_id" gorm:"default:0;not null;index"` ForceAlwaysRelay bool `json:"forceAlwaysRelay" gorm:"default:0;not null;"` RdpPort string `json:"rdpPort" gorm:"default:'';not null;"` RdpUsername string `json:"rdpUsername" gorm:"default:'';not null;"` Online bool `json:"online" gorm:"default:0;not null;"` LoginName string `json:"loginName" gorm:"default:'';not null;"` SameServer bool `json:"sameServer" gorm:"default:0;not null;"` CollectionId uint `json:"collection_id" gorm:"default:0;not null;index"` Collection *AddressBookCollection `json:"collection,omitempty"` TimeModel }
AddressBook 有些字段是Personal才会上传的
type AddressBookCollection ¶
type AddressBookCollectionList ¶
type AddressBookCollectionList struct { AddressBookCollection []*AddressBookCollection `json:"list"` Pagination }
type AddressBookCollectionRule ¶
type AddressBookCollectionRule struct { IdModel UserId uint `json:"user_id" gorm:"default:0;not null;"` CollectionId uint `json:"collection_id" gorm:"default:0;not null;index" validate:"required"` Rule int `json:"rule" gorm:"default:0;not null;" validate:"required,gte=1,lte=3"` // 0: 无 1: 读 2: 读写 3: 完全控制 Type int `json:"type" gorm:"default:1;not null;" validate:"required,gte=1,lte=2"` // 1: 个人 2: 群组 ToId uint `json:"to_id" gorm:"default:0;not null;" validate:"required,gt=0"` TimeModel }
type AddressBookCollectionRuleList ¶
type AddressBookCollectionRuleList struct { AddressBookCollectionRule []*AddressBookCollectionRule `json:"list"` Pagination }
type AddressBookList ¶
type AddressBookList struct { AddressBooks []*AddressBook `json:"list"` Pagination }
type AuditConn ¶
type AuditConn struct { IdModel Action string `json:"action" gorm:"default:'';not null;"` ConnId int64 `json:"conn_id" gorm:"default:0;not null;index"` PeerId string `json:"peer_id" gorm:"default:'';not null;index"` FromPeer string `json:"from_peer" gorm:"default:'';not null;"` FromName string `json:"from_name" gorm:"default:'';not null;"` Ip string `json:"ip" gorm:"default:'';not null;"` SessionId string `json:"session_id" gorm:"default:'';not null;"` Type int `json:"type" gorm:"default:0;not null;"` Uuid string `json:"uuid" gorm:"default:'';not null;"` CloseTime int64 `json:"close_time" gorm:"default:0;not null;"` TimeModel }
type AuditConnList ¶
type AuditConnList struct { AuditConns []*AuditConn `json:"list"` Pagination }
type AuditFile ¶
type AuditFile struct { IdModel FromPeer string `json:"from_peer" gorm:"default:'';not null;index"` Info string `json:"info" gorm:"default:'';not null;"` IsFile bool `json:"is_file" gorm:"default:0;not null;"` Path string `json:"path" gorm:"default:'';not null;"` PeerId string `json:"peer_id" gorm:"default:'';not null;index"` Type int `json:"type" gorm:"default:0;not null;"` Uuid string `json:"uuid" gorm:"default:'';not null;"` Ip string `json:"ip" gorm:"default:'';not null;"` Num int `json:"num" gorm:"default:0;not null;"` FromName string `json:"from_name" gorm:"default:'';not null;"` TimeModel }
type AuditFileList ¶
type AuditFileList struct { AuditFiles []*AuditFile `json:"list"` Pagination }
type GithubUser ¶
type GithubUser struct { OauthUserBase Id int `json:"id"` Login string `json:"login"` AvatarUrl string `json:"avatar_url"` VerifiedEmail bool `json:"verified_email"` }
func (*GithubUser) ToOauthUser ¶
func (gu *GithubUser) ToOauthUser() *OauthUser
type GroupList ¶
type GroupList struct { Groups []*Group `json:"list"` Pagination }
type LoginLog ¶
type LoginLog struct { IdModel UserId uint `json:"user_id" gorm:"default:0;not null;"` Client string `json:"client"` //webadmin,webclient,app, DeviceId string `json:"device_id"` Uuid string `json:"uuid"` Ip string `json:"ip"` Type string `json:"type"` //account,oauth Platform string `json:"platform"` //windows,linux,mac,android,ios UserTokenId uint `json:"user_token_id" gorm:"default:0;not null;"` IsDeleted uint `json:"is_deleted" gorm:"default:0;not null;"` TimeModel }
type LoginLogList ¶
type LoginLogList struct { LoginLogs []*LoginLog `json:"list"` Pagination }
type Oauth ¶
type Oauth struct { IdModel Op string `json:"op"` OauthType string `json:"oauth_type"` ClientId string `json:"client_id"` ClientSecret string `json:"client_secret"` RedirectUrl string `json:"redirect_url"` AutoRegister *bool `json:"auto_register"` Scopes string `json:"scopes"` Issuer string `json:"issuer"` PkceEnable *bool `json:"pkce_enable"` PkceMethod string `json:"pkce_method"` TimeModel }
func (*Oauth) FormatOauthInfo ¶
Helper function to format oauth info, it's used in the update and create method
type OauthList ¶
type OauthList struct { Oauths []*Oauth `json:"list"` Pagination }
type OauthUser ¶
type OauthUserBase ¶
type OidcUser ¶
type OidcUser struct { OauthUserBase Sub string `json:"sub"` VerifiedEmail bool `json:"email_verified"` PreferredUsername string `json:"preferred_username"` Picture string `json:"picture"` }
func (*OidcUser) ToOauthUser ¶
type Pagination ¶
type Pagination struct { Page int64 `form:"page" json:"page"` Total int64 `form:"total" json:"total"` PageSize int64 `form:"page_size" json:"page_size"` }
Pagination
type Peer ¶
type Peer struct { RowId uint `json:"row_id" gorm:"primaryKey;"` Id string `json:"id" gorm:"default:'';not null;index"` Cpu string `json:"cpu" gorm:"default:'';not null;"` Hostname string `json:"hostname" gorm:"default:'';not null;"` Memory string `json:"memory" gorm:"default:'';not null;"` Os string `json:"os" gorm:"default:'';not null;"` Username string `json:"username" gorm:"default:'';not null;"` Uuid string `json:"uuid" gorm:"default:'';not null;index"` Version string `json:"version" gorm:"default:'';not null;"` UserId uint `json:"user_id" gorm:"default:0;not null;index"` User *User `json:"user,omitempty"` LastOnlineTime int64 `json:"last_online_time" gorm:"default:0;not null;"` LastOnlineIp string `json:"last_online_ip" gorm:"default:'';not null;"` TimeModel }
type PeerList ¶
type PeerList struct { Peers []*Peer `json:"list"` Pagination }
type ServerCmd ¶
type ServerCmd struct { IdModel Cmd string `json:"cmd" gorm:"default:'';not null;"` Alias string `json:"alias" gorm:"default:'';not null;"` Option string `json:"option" gorm:"default:'';not null;"` Explain string `json:"explain" gorm:"default:'';not null;"` Target string `json:"target" gorm:"default:'';not null;"` TimeModel }
type ServerCmdList ¶
type ServerCmdList struct { ServerCmds []*ServerCmd `json:"list"` Pagination }
type ShareRecord ¶
type ShareRecord struct {}
type StatusCode ¶
type StatusCode int
const ( COMMON_STATUS_ENABLE StatusCode = 1 //通用状态 启用 COMMON_STATUS_DISABLED StatusCode = 2 //通用状态 禁用 )
type Tag ¶
type Tag struct { IdModel Name string `json:"name" gorm:"default:'';not null;"` UserId uint `json:"user_id" gorm:"default:0;not null;index"` Color uint `json:"color" gorm:"default:0;not null;"` //color 是flutter的颜色值,从0x00000000 到 0xFFFFFFFF; 前两位表示透明度,后面6位表示颜色, 可以转成rgba CollectionId uint `json:"collection_id" gorm:"default:0;not null;index"` Collection *AddressBookCollection `json:"collection,omitempty"` TimeModel }
type TagList ¶
type TagList struct { Tags []*Tag `json:"list"` Pagination }
type TimeModel ¶
type TimeModel struct { CreatedAt custom_types.AutoTime `json:"created_at" gorm:"type:timestamp;"` UpdatedAt custom_types.AutoTime `json:"updated_at" gorm:"type:timestamp;"` }
type User ¶
type User struct { IdModel Username string `json:"username" gorm:"default:'';not null;uniqueIndex"` Email string `json:"email" gorm:"default:'';not null;index"` // Email string `json:"email" ` Password string `json:"-" gorm:"default:'';not null;"` Nickname string `json:"nickname" gorm:"default:'';not null;"` Avatar string `json:"avatar" gorm:"default:'';not null;"` GroupId uint `json:"group_id" gorm:"default:0;not null;index"` IsAdmin *bool `json:"is_admin" gorm:"default:0;not null;"` Status StatusCode `json:"status" gorm:"default:1;not null;"` TimeModel }
type UserList ¶
type UserList struct { Users []*User `json:"list,omitempty"` Pagination }
type UserThird ¶
type UserThird struct { IdModel UserId uint `json:"user_id" gorm:"not null;index"` OauthUser UnionId string `json:"union_id" gorm:"default:'';not null;"` // OauthType string `json:"oauth_type" gorm:"not null;"` ThirdType string `json:"third_type" gorm:"default:'';not null;"` //deprecated OauthType string `json:"oauth_type" gorm:"default:'';not null;"` Op string `json:"op" gorm:"default:'';not null;"` TimeModel }
type UserToken ¶
type UserToken struct { IdModel UserId uint `json:"user_id" gorm:"default:0;not null;index"` DeviceUuid string `json:"device_uuid" gorm:"default:'';omitempty;"` DeviceId string `json:"device_id" gorm:"default:'';omitempty;"` Token string `json:"token" gorm:"default:'';not null;index"` ExpiredAt int64 `json:"expired_at" gorm:"default:0;not null;"` TimeModel }
type UserTokenList ¶
type UserTokenList struct { UserTokens []UserToken `json:"list"` Pagination }
Source Files
¶
Click to show internal directories.
Click to hide internal directories.