2021-07-30 17:46:38 +02:00
|
|
|
package server
|
|
|
|
|
2021-09-02 14:41:54 +02:00
|
|
|
import (
|
2022-03-26 12:08:54 +01:00
|
|
|
"github.com/netbirdio/netbird/management/server/idp"
|
|
|
|
"github.com/netbirdio/netbird/util"
|
2022-05-05 20:02:15 +02:00
|
|
|
"net/url"
|
2021-09-02 14:41:54 +02:00
|
|
|
)
|
|
|
|
|
2021-07-30 17:46:38 +02:00
|
|
|
type Protocol string
|
|
|
|
|
|
|
|
const (
|
|
|
|
UDP Protocol = "udp"
|
|
|
|
DTLS Protocol = "dtls"
|
|
|
|
TCP Protocol = "tcp"
|
|
|
|
HTTP Protocol = "http"
|
|
|
|
HTTPS Protocol = "https"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Config of the Management service
|
|
|
|
type Config struct {
|
2021-09-02 14:41:54 +02:00
|
|
|
Stuns []*Host
|
|
|
|
TURNConfig *TURNConfig
|
|
|
|
Signal *Host
|
2021-07-30 17:46:38 +02:00
|
|
|
|
2021-08-07 13:35:52 +02:00
|
|
|
Datadir string
|
2021-08-07 12:26:07 +02:00
|
|
|
|
|
|
|
HttpConfig *HttpServerConfig
|
2022-01-24 11:21:30 +01:00
|
|
|
|
|
|
|
IdpManagerConfig *idp.Config
|
2021-08-07 12:26:07 +02:00
|
|
|
}
|
|
|
|
|
2021-09-02 14:41:54 +02:00
|
|
|
// TURNConfig is a config of the TURNCredentialsManager
|
|
|
|
type TURNConfig struct {
|
|
|
|
TimeBasedCredentials bool
|
|
|
|
CredentialsTTL util.Duration
|
2021-09-03 17:47:40 +02:00
|
|
|
Secret string
|
2021-09-02 14:41:54 +02:00
|
|
|
Turns []*Host
|
|
|
|
}
|
|
|
|
|
2021-08-07 13:35:52 +02:00
|
|
|
// HttpServerConfig is a config of the HTTP Management service server
|
2021-08-07 12:26:07 +02:00
|
|
|
type HttpServerConfig struct {
|
2021-08-07 13:35:52 +02:00
|
|
|
LetsEncryptDomain string
|
2021-09-25 19:22:49 +02:00
|
|
|
//CertFile is the location of the certificate
|
|
|
|
CertFile string
|
|
|
|
//CertKey is the location of the certificate private key
|
|
|
|
CertKey string
|
|
|
|
Address string
|
2021-08-12 12:49:10 +02:00
|
|
|
// AuthAudience identifies the recipients that the JWT is intended for (aud in JWT)
|
|
|
|
AuthAudience string
|
|
|
|
// AuthIssuer identifies principal that issued the JWT.
|
|
|
|
AuthIssuer string
|
|
|
|
// AuthKeysLocation is a location of JWT key set containing the public keys used to verify JWT
|
|
|
|
AuthKeysLocation string
|
2021-07-30 17:46:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Host represents a Wiretrustee host (e.g. STUN, TURN, Signal)
|
|
|
|
type Host struct {
|
|
|
|
Proto Protocol
|
|
|
|
// URI e.g. turns://stun.wiretrustee.com:4430 or signal.wiretrustee.com:10000
|
|
|
|
URI string
|
|
|
|
Username string
|
2021-09-03 17:47:40 +02:00
|
|
|
Password string
|
2021-07-30 17:46:38 +02:00
|
|
|
}
|
2022-05-05 20:02:15 +02:00
|
|
|
|
|
|
|
// validateURL validates input http url
|
|
|
|
func validateURL(httpURL string) bool {
|
|
|
|
_, err := url.ParseRequestURI(httpURL)
|
|
|
|
if err != nil {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|