extclient.go 3.9 KB

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