MCPcopy Create free account
hub / github.com/TelegramMessenger/cocoon / wait_auth

Method wait_auth

tee/cocoon/FwdProxy.cpp:88–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

86 }
87
88 td::Status wait_auth() {
89 auto buf = pipe_.input_buffer().clone();
90 TRY_RESULT(header, read(buf, 2));
91 td::uint8 version = header[0];
92 if (version != 0x1) {
93 return td::Status::Error(PSLICE() << "Invalid socks5 auth version " << version << ", expected 0x1");
94 }
95 td::uint8 user_length = header[1];
96 TRY_RESULT(user, read(buf, user_length));
97
98 TRY_RESULT(header2, read(buf, 1));
99 td::uint8 password_length = header2[0];
100 TRY_RESULT(password, read(buf, password_length));
101
102 TRY_STATUS(set_policy_name(user));
103
104 pipe_.input_buffer() = std::move(buf);
105
106 unsigned char ans[2];
107 ans[0] = 0x1; // version
108 ans[1] = 0x0; // status
109 pipe_.output_buffer().append(td::Slice(ans, 2));
110 state_ = State::WaitRequest;
111 return td::Status::OK();
112 }
113
114 td::Status set_policy_name(const std::string &policy_name) {
115 LOG(ERROR) << "set policy name = " << policy_name;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected