mirror of
https://github.com/boringproxy/boringproxy.git
synced 2025-02-25 18:55:29 -06:00
Move password handling so we can extract it
This commit is contained in:
@@ -16,14 +16,7 @@ type SshServer struct {
|
||||
|
||||
|
||||
func NewSshServer() *SshServer {
|
||||
config := &ssh.ServerConfig{
|
||||
PasswordCallback: func(c ssh.ConnMetadata, pass []byte) (*ssh.Permissions, error) {
|
||||
if c.User() == "user" && string(pass) == "yolo" {
|
||||
return nil, nil
|
||||
}
|
||||
return nil, fmt.Errorf("password rejected for %q", c.User())
|
||||
},
|
||||
}
|
||||
config := &ssh.ServerConfig{}
|
||||
|
||||
privateBytes, err := ioutil.ReadFile("id_rsa_boringproxy")
|
||||
if err != nil {
|
||||
@@ -63,12 +56,24 @@ func (s *SshServer) acceptAll() {
|
||||
|
||||
func (s *SshServer) handleServerConn(nConn net.Conn) {
|
||||
|
||||
var password string
|
||||
|
||||
s.config.PasswordCallback = func(c ssh.ConnMetadata, pass []byte) (*ssh.Permissions, error) {
|
||||
password = string(pass)
|
||||
if c.User() == "user" && string(pass) == "yolo" {
|
||||
return nil, nil
|
||||
}
|
||||
return nil, fmt.Errorf("password rejected for %q", c.User())
|
||||
}
|
||||
|
||||
conn, chans, reqs, err := ssh.NewServerConn(nConn, s.config)
|
||||
if err != nil {
|
||||
log.Print("failed to handshake: ", err)
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println(password)
|
||||
|
||||
go ssh.DiscardRequests(reqs)
|
||||
|
||||
go func() {
|
||||
|
||||
Reference in New Issue
Block a user