(route string, uuid string)
| 31 | } |
| 32 | |
| 33 | func (ssh *SSH) LetSSH(route string, uuid string) error { |
| 34 | _, _, err := utils.CheckIPPort(ssh.Addr) |
| 35 | if err != nil { |
| 36 | return err |
| 37 | } |
| 38 | |
| 39 | if ssh.Method == CERMETHOD { |
| 40 | if err := ssh.getCertificate(); err != nil { |
| 41 | return err |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | sMessage := protocol.PrepareAndDecideWhichSProtoToLower(global.G_Component.Conn, global.G_Component.Secret, global.G_Component.UUID) |
| 46 | |
| 47 | header := &protocol.Header{ |
| 48 | Sender: protocol.ADMIN_UUID, |
| 49 | Accepter: uuid, |
| 50 | MessageType: protocol.SSHREQ, |
| 51 | RouteLen: uint32(len([]byte(route))), |
| 52 | Route: route, |
| 53 | } |
| 54 | |
| 55 | sshReqMess := &protocol.SSHReq{ |
| 56 | Method: uint16(ssh.Method), |
| 57 | AddrLen: uint16(len(ssh.Addr)), |
| 58 | Addr: ssh.Addr, |
| 59 | UsernameLen: uint64(len(ssh.Username)), |
| 60 | Username: ssh.Username, |
| 61 | PasswordLen: uint64(len(ssh.Password)), |
| 62 | Password: ssh.Password, |
| 63 | CertificateLen: uint64(len(ssh.Certificate)), |
| 64 | Certificate: ssh.Certificate, |
| 65 | } |
| 66 | |
| 67 | protocol.ConstructMessage(sMessage, header, sshReqMess, false) |
| 68 | sMessage.SendMessage() |
| 69 | |
| 70 | return nil |
| 71 | } |
| 72 | |
| 73 | func (ssh *SSH) getCertificate() (err error) { |
| 74 | ssh.Certificate, err = ioutil.ReadFile(ssh.CertificatePath) |
no test coverage detected