mirror of
https://github.com/mumble-voip/grumble.git
synced 2025-12-20 06:10:00 -08:00
Refine auto-keypair regen functionality. Complain loudly if only one of (cert.pem, key.pem) exists.
This commit is contained in:
parent
76747e0b71
commit
b94b04d2de
4 changed files with 67 additions and 42 deletions
54
ssh.go
54
ssh.go
|
|
@ -72,7 +72,7 @@ func RunSSH() {
|
|||
"<id> <key> <value>",
|
||||
"Get a config value for the server with the given id")
|
||||
|
||||
pemBytes, err := ioutil.ReadFile(filepath.Join(Args.DataDir, "key"))
|
||||
pemBytes, err := ioutil.ReadFile(filepath.Join(Args.DataDir, "key.pem"))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
|
@ -89,32 +89,34 @@ func RunSSH() {
|
|||
|
||||
log.Printf("Listening for SSH connections on '%v'", Args.SshAddr)
|
||||
|
||||
for {
|
||||
conn, err := listener.Accept()
|
||||
if err != nil {
|
||||
log.Fatalf("ssh: unable to accept incoming connection: %v", err)
|
||||
}
|
||||
|
||||
err = conn.Handshake()
|
||||
if err == io.EOF {
|
||||
continue
|
||||
} else if err != nil {
|
||||
log.Fatalf("ssh: unable to perform handshake: %v", err)
|
||||
}
|
||||
|
||||
go func() {
|
||||
for {
|
||||
channel, err := conn.Accept()
|
||||
if err == io.EOF {
|
||||
return
|
||||
} else if err != nil {
|
||||
log.Fatalf("ssh: unable to accept channel: %v", err)
|
||||
}
|
||||
|
||||
go handleChannel(channel)
|
||||
go func() {
|
||||
for {
|
||||
conn, err := listener.Accept()
|
||||
if err != nil {
|
||||
log.Fatalf("ssh: unable to accept incoming connection: %v", err)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
err = conn.Handshake()
|
||||
if err == io.EOF {
|
||||
continue
|
||||
} else if err != nil {
|
||||
log.Fatalf("ssh: unable to perform handshake: %v", err)
|
||||
}
|
||||
|
||||
go func() {
|
||||
for {
|
||||
channel, err := conn.Accept()
|
||||
if err == io.EOF {
|
||||
return
|
||||
} else if err != nil {
|
||||
log.Fatalf("ssh: unable to accept channel: %v", err)
|
||||
}
|
||||
|
||||
go handleChannel(channel)
|
||||
}
|
||||
}()
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
func handleChannel(channel ssh.Channel) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue