Proxy settings
Gogram supports proxies with and without authentication. This feature allows you to exchange data with Telegram through an intermediate SOCKS 4/5 or HTTP proxy server.
Usage
To use a proxy, you need to create a ClientConfig
object and set the Proxy
field to a url.URL
object. The url.URL
object should contain the proxy server's address and port.
if your proxy does not require authentication, you can set the User
field to nil
.
proxy.go
package main
import (
"net/url"
"github.com/amarnathcjd/gogram/telegram"
)
func main() {
// Create a new client
client := telegram.NewClient(&telegram.ClientConfig{
AppID: 12345,
AppHash: "0123456789abcdef0123456789abcdef",
Proxy: &url.URL{
Scheme: "socks5",
Host: "127.0.0.1:1080",
user: url.UserPassword("username", "password"),
},
})
client.Start() // Start the client
}
If proxy connection is successfull, you can see the ipAddress of the proxy in the logs.
mtproxy is not supported yet.