extclient.go 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. }
  29. // CustomExtClient - struct for CustomExtClient params
  30. type CustomExtClient struct {
  31. ClientID string `json:"clientid,omitempty"`
  32. PublicKey string `json:"publickey,omitempty"`
  33. DNS string `json:"dns,omitempty"`
  34. ExtraAllowedIPs []string `json:"extraallowedips,omitempty"`
  35. Enabled bool `json:"enabled,omitempty"`
  36. DeniedACLs map[string]struct{} `json:"deniednodeacls" bson:"acls,omitempty"`
  37. RemoteAccessClientID string `json:"remote_access_client_id"` // unique ID (MAC address) of RAC machine
  38. PostUp string `json:"postup" bson:"postup" validate:"max=1024"`
  39. PostDown string `json:"postdown" bson:"postdown" validate:"max=1024"`
  40. Tags map[TagID]struct{} `json:"tags"`
  41. Os string `json:"os"`
  42. DeviceName string `json:"device_name"`
  43. IsAlreadyConnectedToInetGw bool `json:"is_already_connected_to_inet_gw"`
  44. PublicEndpoint string `json:"public_endpoint"`
  45. Country string `json:"country"`
  46. }
  47. func (ext *ExtClient) ConvertToStaticNode() Node {
  48. return Node{
  49. CommonNode: CommonNode{
  50. Network: ext.Network,
  51. },
  52. Tags: ext.Tags,
  53. IsStatic: true,
  54. StaticNode: *ext,
  55. Mutex: &sync.RWMutex{},
  56. }
  57. }