structs.go 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. package models
  2. import jwt "github.com/dgrijalva/jwt-go"
  3. type AuthParams struct {
  4. MacAddress string `json:"macaddress"`
  5. Password string `json:"password"`
  6. }
  7. type User struct {
  8. UserName string `json:"username" bson:"username" validate:username_valid,username_unique,min=3`
  9. Password string `json:"password" bson:"password" validate:password_check`
  10. IsAdmin bool `json:"isadmin" bson:"isadmin"`
  11. }
  12. type UserAuthParams struct {
  13. UserName string `json:"username"`
  14. Password string `json:"password"`
  15. }
  16. type UserClaims struct {
  17. IsAdmin bool
  18. UserName string
  19. jwt.StandardClaims
  20. }
  21. type SuccessfulUserLoginResponse struct {
  22. UserName string
  23. AuthToken string
  24. }
  25. // Claims is a struct that will be encoded to a JWT.
  26. // jwt.StandardClaims is an embedded type to provide expiry time
  27. type Claims struct {
  28. Network string
  29. MacAddress string
  30. jwt.StandardClaims
  31. }
  32. // SuccessfulLoginResponse is struct to send the request response
  33. type SuccessfulLoginResponse struct {
  34. MacAddress string
  35. AuthToken string
  36. }
  37. type ErrorResponse struct {
  38. Code int
  39. Message string
  40. }
  41. type NodeAuth struct {
  42. Network string
  43. Password string
  44. MacAddress string
  45. }
  46. // SuccessResponse is struct for sending error message with code.
  47. type SuccessResponse struct {
  48. Code int
  49. Message string
  50. Response interface{}
  51. }
  52. type AccessKey struct {
  53. Name string `json:"name" bson:"name"`
  54. Value string `json:"value" bson:"value"`
  55. AccessString string `json:"accessstring" bson:"accessstring"`
  56. Uses int `json:"uses" bson:"uses"`
  57. }
  58. type DisplayKey struct {
  59. Name string `json:"name" bson:"name"`
  60. Uses int `json:"uses" bson:"uses"`
  61. }
  62. type GlobalConfig struct {
  63. Name string `json:"name" bson:"name"`
  64. PortGRPC string `json:"portgrpc" bson:"portgrpc"`
  65. ServerGRPC string `json:"servergrpc" bson:"servergrpc"`
  66. }
  67. type CheckInResponse struct{
  68. Success bool `json:"success" bson:"success"`
  69. NeedPeerUpdate bool `json:"needpeerupdate" bson:"needpeerupdate"`
  70. NeedConfigUpdate bool `json:"needconfigupdate" bson:"needconfigupdate"`
  71. NeedKeyUpdate bool `json:"needkeyupdate" bson:"needkeyupdate"`
  72. NeedDelete bool `json:"needdelete" bson:"needdelete"`
  73. NodeMessage string `json:"nodemessage" bson:"nodemessage"`
  74. IsPending bool `json:"ispending" bson:"ispending"`
  75. }
  76. type PeersResponse struct {
  77. PublicKey string `json:"publickey" bson:"publickey"`
  78. Endpoint string `json:"endpoint" bson:"endpoint"`
  79. Address string `json:"address" bson:"address"`
  80. LocalAddress string `json:"localaddress" bson:"localaddress"`
  81. IsGateway bool `json:"isgateway" bson:"isgateway"`
  82. GatewayRange string `json:"gatewayrange" bson:"gatewayrange"`
  83. ListenPort int32 `json:"listenport" bson:"listenport"`
  84. KeepAlive int32 `json:"persistentkeepalive" bson:"persistentkeepalive"`
  85. }
  86. type GatewayRequest struct {
  87. NodeID string `json:"nodeid" bson:"nodeid"`
  88. NetID string `json:"netid" bson:"netid"`
  89. RangeString string `json:"rangestring" bson:"rangestring"`
  90. Ranges []string `json:"ranges" bson:"ranges"`
  91. Interface string `json:"interface" bson:"interface"`
  92. PostUp string `json:"postup" bson:"postup"`
  93. PostDown string `json:"postdown" bson:"postdown"`
  94. }