MCPcopy
hub / github.com/ph4ntonn/Stowaway / start

Method start

agent/handler/connect.go:26–197  ·  view source on GitHub ↗
(mgr *manager.Manager)

Source from the content-addressed store, hash-verified

24}
25
26func (connect *Connect) start(mgr *manager.Manager) {
27 var sUMessage, sLMessage, rMessage protocol.Message
28
29 sUMessage = protocol.PrepareAndDecideWhichSProtoToUpper(global.G_Component.Conn, global.G_Component.Secret, global.G_Component.UUID)
30
31 hiHeader := &protocol.Header{
32 Sender: protocol.ADMIN_UUID, // fake admin
33 Accepter: protocol.TEMP_UUID,
34 MessageType: protocol.HI,
35 RouteLen: uint32(len([]byte(protocol.TEMP_ROUTE))),
36 Route: protocol.TEMP_ROUTE,
37 }
38
39 // fake admin
40 hiMess := &protocol.HIMess{
41 GreetingLen: uint16(len("Shhh...")),
42 Greeting: "Shhh...",
43 UUIDLen: uint16(len(protocol.ADMIN_UUID)),
44 UUID: protocol.ADMIN_UUID,
45 IsAdmin: 1,
46 IsReconnect: 0,
47 }
48
49 doneHeader := &protocol.Header{
50 Sender: global.G_Component.UUID,
51 Accepter: protocol.ADMIN_UUID,
52 MessageType: protocol.CONNECTDONE,
53 RouteLen: uint32(len([]byte(protocol.TEMP_ROUTE))),
54 Route: protocol.TEMP_ROUTE,
55 }
56
57 doneSuccMess := &protocol.ConnectDone{
58 OK: 1,
59 }
60
61 doneFailMess := &protocol.ConnectDone{
62 OK: 0,
63 }
64
65 var (
66 conn net.Conn
67 err error
68 )
69
70 defer func() {
71 if err != nil {
72 protocol.ConstructMessage(sUMessage, doneHeader, doneFailMess, false)
73 sUMessage.SendMessage()
74 }
75 }()
76
77 conn, err = net.DialTimeout("tcp", connect.Addr, 10*time.Second)
78
79 if err != nil {
80 return
81 }
82
83 if err = share.ActivePreAuth(conn); err != nil {

Callers 1

DispatchConnectMessFunction · 0.45

Calls 9

SendMessageMethod · 0.95
ConstructMessageFunction · 0.92
ActivePreAuthFunction · 0.92
NewClientTLSConfigFunction · 0.92
WrapTLSClientConnFunction · 0.92
DestructMessageFunction · 0.92

Tested by

no test coverage detected