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

Function NormalActive

admin/initial/method.go:41–150  ·  view source on GitHub ↗
(userOptions *Options, topo *topology.Topology, proxy share.Proxy)

Source from the content-addressed store, hash-verified

39}
40
41func NormalActive(userOptions *Options, topo *topology.Topology, proxy share.Proxy) net.Conn {
42
43 var sMessage, rMessage protocol.Message
44
45 hiMess := &protocol.HIMess{
46 GreetingLen: uint16(len("Shhh...")),
47 Greeting: "Shhh...",
48 UUIDLen: uint16(len(protocol.ADMIN_UUID)),
49 UUID: protocol.ADMIN_UUID,
50 IsAdmin: 1,
51 IsReconnect: 0,
52 }
53
54 header := &protocol.Header{
55 Sender: protocol.ADMIN_UUID,
56 Accepter: protocol.TEMP_UUID,
57 MessageType: protocol.HI,
58 RouteLen: uint32(len([]byte(protocol.TEMP_ROUTE))),
59 Route: protocol.TEMP_ROUTE,
60 }
61
62 for {
63 var (
64 conn net.Conn
65 err error
66 )
67
68 if proxy == nil {
69 conn, err = net.Dial("tcp", userOptions.Connect)
70 } else {
71 conn, err = proxy.Dial()
72 }
73
74 if err != nil {
75 printer.Fail("[*] Error occurred: %s", err.Error())
76 os.Exit(0)
77 }
78
79 if err := share.ActivePreAuth(conn); err != nil {
80 printer.Fail("[*] Error occurred: %s", err.Error())
81 os.Exit(0)
82 }
83
84 if userOptions.TlsEnable {
85 var tlsConfig *tls.Config
86 tlsConfig, err = transport.NewClientTLSConfig(userOptions.Domain)
87 if err != nil {
88 printer.Fail("[*] Error occured: %s", err.Error())
89 conn.Close()
90 continue
91 }
92 conn = transport.WrapTLSClientConn(conn, tlsConfig)
93 // As we have already used TLS, we don't need to use aes inside
94 // Set userOptions.Secret as null to disable aes
95 userOptions.Secret = ""
96 }
97
98 sMessage = protocol.PrepareAndDecideWhichSProtoToLower(conn, userOptions.Secret, protocol.ADMIN_UUID)

Callers 2

mainFunction · 0.92
mainFunction · 0.92

Calls 11

SendMessageMethod · 0.95
ActivePreAuthFunction · 0.92
NewClientTLSConfigFunction · 0.92
WrapTLSClientConnFunction · 0.92
ConstructMessageFunction · 0.92
DestructMessageFunction · 0.92
NewNodeFunction · 0.92
dispatchUUIDFunction · 0.85
DialMethod · 0.65

Tested by

no test coverage detected