MCPcopy Create free account
hub / github.com/IceFireDB/IceFireDB / NewServer

Function NewServer

IceFireDB-SQLite/pkg/mysql/server/server_conf.go:72–95  ·  view source on GitHub ↗

NewServer: New mysql server with customized settings. NOTES: You can control the authentication methods and TLS settings here. For auth method, you can specify one of the supported methods 'mysql_native_password', 'caching_sha2_password', and 'sha256_password'. The specified auth method will be enf

(serverVersion string, collationId uint8, defaultAuthMethod string, pubKey []byte, tlsConfig *tls.Config)

Source from the content-addressed store, hash-verified

70// And for TLS support, you can specify self-signed or CA-signed certificates and decide whether the client needs to provide
71// a signed or unsigned certificate to provide different level of security.
72func NewServer(serverVersion string, collationId uint8, defaultAuthMethod string, pubKey []byte, tlsConfig *tls.Config) *Server {
73 if !isAuthMethodSupported(defaultAuthMethod) {
74 panic(fmt.Sprintf("server authentication method '%s' is not supported", defaultAuthMethod))
75 }
76
77 //if !isAuthMethodAllowedByServer(defaultAuthMethod, allowedAuthMethods) {
78 // panic(fmt.Sprintf("default auth method is not one of the allowed auth methods"))
79 //}
80 capFlag := CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG | CLIENT_CONNECT_WITH_DB | CLIENT_PROTOCOL_41 |
81 CLIENT_TRANSACTIONS | CLIENT_SECURE_CONNECTION | CLIENT_PLUGIN_AUTH | CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA
82 if tlsConfig != nil {
83 capFlag |= CLIENT_SSL
84 }
85 return &Server{
86 serverVersion: serverVersion,
87 protocolVersion: 10,
88 capability: capFlag,
89 collationId: collationId,
90 defaultAuthMethod: defaultAuthMethod,
91 pubKey: pubKey,
92 tlsConfig: tlsConfig,
93 cacheShaPassword: new(sync.Map),
94 }
95}
96
97func isAuthMethodSupported(authMethod string) bool {
98 return authMethod == AUTH_NATIVE_PASSWORD || authMethod == AUTH_CACHING_SHA2_PASSWORD || authMethod == AUTH_SHA256_PASSWORD

Callers

nothing calls this directly

Calls 1

isAuthMethodSupportedFunction · 0.70

Tested by

no test coverage detected