extclient.go 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. package models
  2. import "sync"
  3. // ExtClient - struct for external clients
  4. type ExtClient struct {
  5. ClientID string `json:"clientid" bson:"clientid"`
  6. PrivateKey string `json:"privatekey" bson:"privatekey"`
  7. PublicKey string `json:"publickey" bson:"publickey"`
  8. Network string `json:"network" bson:"network"`
  9. DNS string `json:"dns" bson:"dns"`
  10. Address string `json:"address" bson:"address"`
  11. Address6 string `json:"address6" bson:"address6"`
  12. ExtraAllowedIPs []string `json:"extraallowedips" bson:"extraallowedips"`
  13. AllowedIPs []string `json:"allowed_ips"`
  14. IngressGatewayID string `json:"ingressgatewayid" bson:"ingressgatewayid"`
  15. IngressGatewayEndpoint string `json:"ingressgatewayendpoint" bson:"ingressgatewayendpoint"`
  16. LastModified int64 `json:"lastmodified" bson:"lastmodified" swaggertype:"primitive,integer" format:"int64"`
  17. Enabled bool `json:"enabled" bson:"enabled"`
  18. OwnerID string `json:"ownerid" bson:"ownerid"`
  19. DeniedACLs map[string]struct{} `json:"deniednodeacls" bson:"acls,omitempty"`
  20. RemoteAccessClientID string `json:"remote_access_client_id"` // unique ID (MAC address) of RAC machine
  21. PostUp string `json:"postup" bson:"postup"`
  22. PostDown string `json:"postdown" bson:"postdown"`
  23. Tags map[TagID]struct{} `json:"tags"`
  24. Os string `json:"os"`
  25. DeviceName string `json:"device_name"`
  26. PublicEndpoint string `json:"public_endpoint"`
  27. Country string `json:"country"`
  28. Mutex *sync.Mutex `json:"-"`
  29. }
  30. // CustomExtClient - struct for CustomExtClient params
  31. type CustomExtClient struct {
  32. ClientID string `json:"clientid,omitempty"`
  33. PublicKey string `json:"publickey,omitempty"`
  34. DNS string `json:"dns,omitempty"`
  35. ExtraAllowedIPs []string `json:"extraallowedips,omitempty"`
  36. Enabled bool `json:"enabled,omitempty"`
  37. DeniedACLs map[string]struct{} `json:"deniednodeacls" bson:"acls,omitempty"`
  38. RemoteAccessClientID string `json:"remote_access_client_id"` // unique ID (MAC address) of RAC machine
  39. PostUp string `json:"postup" bson:"postup" validate:"max=1024"`
  40. PostDown string `json:"postdown" bson:"postdown" validate:"max=1024"`
  41. Tags map[TagID]struct{} `json:"tags"`
  42. Os string `json:"os"`
  43. DeviceName string `json:"device_name"`
  44. IsAlreadyConnectedToInetGw bool `json:"is_already_connected_to_inet_gw"`
  45. PublicEndpoint string `json:"public_endpoint"`
  46. Country string `json:"country"`
  47. }
  48. func (ext *ExtClient) ConvertToStaticNode() Node {
  49. return Node{
  50. CommonNode: CommonNode{
  51. Network: ext.Network,
  52. },
  53. Tags: ext.Tags,
  54. IsStatic: true,
  55. StaticNode: *ext,
  56. Mutex: ext.Mutex,
  57. }
  58. }