extclient.go 3.8 KB

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