After purchasing static IP services from the IPNut platform (example credentials:
Endpoint:
http://proxy.ipnut.com:28001Username:
ipnutPassword:
123456789),
use the following Go code samples for integration.
1. SOCKS5 Proxy Example #
package main
import (
"crypto/tls"
"fmt"
"io"
"net/http"
"net/url"
"time"
"golang.org/x/net/proxy"
)
func socks5ProxyDemo() {
fmt.Println("=== SOCKS5 Proxy Demo ===")
// Configure SOCKS5 proxy parameters
proxyHost := "proxy.ipnut.com"
proxyPort := "28001"
proxyUsername := "ipnut"
proxyPassword := "123456789"
// Create authenticated SOCKS5 dialer
auth := &proxy.Auth{
User: proxyUsername,
Password: proxyPassword,
}
dialer, err := proxy.SOCKS5("tcp",
fmt.Sprintf("%s:%s", proxyHost, proxyPort),
auth,
proxy.Direct,
)
if err != nil {
fmt.Printf("SOCKS5 dialer initialization failed: %v\n", err)
return
}
// Configure HTTP transport with SOCKS5 dialer
httpTransport := &http.Transport{
Dial: dialer.Dial,
TLSClientConfig: &tls.Config{
InsecureSkipVerify: false, // Enable certificate verification in production
},
MaxIdleConns: 100,
IdleConnTimeout: 90 * time.Second,
TLSHandshakeTimeout: 10 * time.Second,
}
// Initialize HTTP client
client := &http.Client{
Transport: httpTransport,
Timeout: 30 * time.Second,
}
// Execute test request
testURL := "https://httpbin.org/ip"
fmt.Printf("Accessing via SOCKS5: %s\n", testURL)
resp, err := client.Get(testURL)
if err != nil {
fmt.Printf("Request failed: %v\n", err)
return
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
fmt.Printf("Response read failed: %v\n", err)
return
}
fmt.Printf("Status Code: %d\n", resp.StatusCode)
fmt.Printf("Response Body: %s\n", string(body))
}
2. HTTP Proxy Example #
func httpProxyDemo() {
fmt.Println("=== HTTP Proxy Demo ===")
// HTTP proxy configuration
proxyHost := "proxy.ipnut.com"
proxyPort := "28001"
proxyUsername := "ipnut"
proxyPassword := "123456789"
// Construct proxy URL with authentication
proxyURL := fmt.Sprintf("http://%s:%s@%s:%s",
url.QueryEscape(proxyUsername),
url.QueryEscape(proxyPassword),
proxyHost,
proxyPort)
parsedProxy, err := url.Parse(proxyURL)
if err != nil {
fmt.Printf("Proxy URL parsing failed: %v\n", err)
return
}
// Configure HTTP transport with proxy
httpTransport := &http.Transport{
Proxy: http.ProxyURL(parsedProxy),
TLSClientConfig: &tls.Config{
InsecureSkipVerify: false, // Disable in production
},
MaxIdleConns: 100,
IdleConnTimeout: 90 * time.Second,
TLSHandshakeTimeout: 10 * time.Second,
}
client := &http.Client{
Transport: httpTransport,
Timeout: 30 * time.Second,
}
// Test request with custom headers
req, err := http.NewRequest("GET", "https://httpbin.org/headers", nil)
if err != nil {
fmt.Printf("Request creation failed: %v\n", err)
return
}
req.Header.Set("User-Agent", "IPNut-Go-Client/1.0")
resp, err := client.Do(req)
if err != nil {
fmt.Printf("Request execution failed: %v\n", err)
return
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
fmt.Printf("Response read failed: %v\n", err)
return
}
fmt.Printf("Status Code: %d\n", resp.StatusCode)
fmt.Printf("Response: %s\n", string(body))
}
3. Main Function & Project Configuration #
func main() {
fmt.Println("Starting IPNut Proxy Connectivity Tests...\n")
// Execute proxy demonstrations
socks5ProxyDemo()
fmt.Println("\n" + "="*50 + "\n")
httpProxyDemo()
fmt.Println("\nAll proxy tests completed!")
}
4. Go Module Configuration #
module ipnut-proxy-demo
go 1.21
require (
golang.org/x/net v0.17.0
)
5. Execution Commands: #
# Initialize module
go mod init ipnut-proxy-demo
# Install dependencies
go mod tidy
# Execute demonstration
go run main.go
Key Integration Notes:
Replace example credentials with actual IPNut proxy details
Enable proper TLS certificate verification in production environments
Implement connection pooling for high-throughput applications
Add retry mechanisms for enhanced reliability
Technical Support
For integration assistance or location-specific requirements:
Email: Support@ipnut.com
Live Chat: 24/7 via official website
*All code examples support both HTTP(S) and SOCKS5 protocols with enterprise-grade authentication.*