Last active
November 27, 2021 20:42
-
-
Save MihaZupan/3b0808e4d50bcf379e63c1b0e21b4cd8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
readonly HttpToSocks5Proxy Socks5Proxy = new HttpToSocks5Proxy("proxyAddress", 1080); | |
TcpClient TcpOverSocks5ClientConnectionHandler(string address, int port) | |
{ | |
string connectMessage = string.Format( | |
"CONNECT {0} HTTP/1.1\r\nHost: {0}\r\n\r\n", | |
address + ":" + port); | |
byte[] connectMessageBytes = Encoding.UTF8.GetBytes(connectMessage); | |
TcpClient newClient = new TcpClient("localhost", Socks5Proxy.InternalServerPort); | |
var stream = newClient.GetStream(); | |
stream.Write(connectMessageBytes, 0, connectMessageBytes.Length); | |
stream.Flush(); | |
stream.Read(new byte[1024], 0, 1024); | |
return newClient; | |
} | |
void DoStuff() | |
{ | |
TelegramClient client = new TelegramClient(123, "hash", handler: TcpOverSocks5ClientConnectionHandler); | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment