mirror of
https://github.com/stulzq/azure-openai-proxy.git
synced 2025-12-19 15:24:24 +01:00
feat: add azure proxy
This commit is contained in:
@@ -4,13 +4,29 @@ import (
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"github.com/stulzq/azure-openai-proxy/constant"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
|
||||
"golang.org/x/net/proxy"
|
||||
)
|
||||
|
||||
func NewProxyFromEnv() (*http.Transport, error) {
|
||||
socksProxy := os.Getenv(constant.ENV_AZURE_OPENAI_SOCKS_PROXY)
|
||||
if socksProxy != "" {
|
||||
return NewSocksProxy(socksProxy)
|
||||
}
|
||||
|
||||
httpProxy := os.Getenv(constant.ENV_AZURE_OPENAI_HTTP_PROXY)
|
||||
if httpProxy != "" {
|
||||
return NewHttpProxy(httpProxy)
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func NewHttpProxy(proxyAddress string) (*http.Transport, error) {
|
||||
proxyURL, err := url.Parse(proxyAddress)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user