-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
20f2894
commit cec99f2
Showing
6 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package plugins | ||
|
||
import ( | ||
"github.com/francoismichel/ssh3/server_auth" | ||
"github.com/francoismichel/ssh3/internal" | ||
) | ||
|
||
// Registers a new server-side auth plugin | ||
func RegisterServerIdentity(name string, identity server_auth.Identity) error { | ||
return internal.RegisterServerIdentity(name, identity) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package main | ||
|
||
import ( | ||
cmd "github.com/francoismichel/ssh3/cmd" | ||
) | ||
|
||
func main() { | ||
cmd.ClientMain() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package internal | ||
|
||
import ( | ||
"sync" | ||
|
||
"github.com/francoismichel/ssh3/server_auth" | ||
. "github.com/francoismichel/ssh3/util" | ||
) | ||
|
||
type serverPluginsRegistry struct { | ||
registrationsOpen bool | ||
serverPluginIdentities map[string]server_auth.Identity | ||
} | ||
|
||
var ( | ||
serverPluginsMutex sync.RWMutex | ||
serverRegistry = &serverPluginsRegistry{ registrationsOpen: true, serverPluginIdentities: make(map[string]server_auth.Identity) } | ||
) | ||
|
||
// Registers a new server-side auth plugin | ||
func RegisterServerIdentity(name string, identity server_auth.Identity) error { | ||
serverPluginsMutex.Lock() | ||
defer serverPluginsMutex.Unlock() | ||
if !serverRegistry.registrationsOpen { | ||
return ClosedPluginsRegistry{} | ||
} | ||
if identity == nil { | ||
panic("plugin registry is nil") | ||
} | ||
if _, dup := serverRegistry.serverPluginIdentities[name]; dup { | ||
panic("RegisterServerIdentity called twice for same auth plugin name " + name) | ||
} | ||
serverRegistry.serverPluginIdentities[name] = identity | ||
return nil | ||
} | ||
|
||
// Closes the registry. This function should not be exported outside the scope of the module | ||
// to avoid plugins closing the registry. | ||
func CloseRegistry() { | ||
serverPluginsMutex.Lock() | ||
defer serverPluginsMutex.Unlock() | ||
serverRegistry.registrationsOpen = false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters