mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-08-31 21:34:02 +03:00
REPOSITORY / ScuroNeko/mtg
Compare commits
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dc81f7981c | ||
|
|
9d5fd989e5 | ||
|
|
81703233b0 | ||
|
|
eb7720b11e | ||
|
|
df7ddc3d6a | ||
|
|
3bc1e415f9 | ||
|
|
306fa19ad6 | ||
|
|
079252d810 |
@@ -20,7 +20,7 @@ func (t *Telegram) GetAddresses(dc int) []Addr {
|
||||
case preferIPOnlyIPv4:
|
||||
return t.view.getV4(dc)
|
||||
case preferIPOnlyIPv6:
|
||||
return t.view.getV4(dc)
|
||||
return t.view.getV6(dc)
|
||||
case preferIPPreferIPv4:
|
||||
return append(t.view.getV4(dc), t.view.getV6(dc)...)
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"io"
|
||||
rnd "math/rand/v2"
|
||||
|
||||
"github.com/9seconds/mtg/v2/mtglib/internal/doppel"
|
||||
"github.com/9seconds/mtg/v2/mtglib/internal/tls"
|
||||
"golang.org/x/crypto/curve25519"
|
||||
)
|
||||
@@ -125,7 +126,14 @@ func generateChangeCipherValue(buf *bytes.Buffer) {
|
||||
}
|
||||
|
||||
func generateNoise(buf *bytes.Buffer) {
|
||||
data := make([]byte, int64(1024+rnd.IntN(3092)))
|
||||
data := make(
|
||||
[]byte,
|
||||
int64(
|
||||
doppel.TLSRecordSizeStart+rnd.IntN(
|
||||
doppel.TLSRecordSizeAccel-doppel.TLSRecordSizeStart,
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
if _, err := rand.Read(data[:]); err != nil {
|
||||
panic(err)
|
||||
|
||||
@@ -3,6 +3,7 @@ package network
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"github.com/9seconds/mtg/v2/essentials"
|
||||
@@ -15,6 +16,10 @@ type proxyNetwork struct {
|
||||
client proxy.ContextDialer
|
||||
}
|
||||
|
||||
func (p proxyNetwork) Dial(network, address string) (essentials.Conn, error) {
|
||||
return p.DialContext(context.Background(), network, address)
|
||||
}
|
||||
|
||||
func (p proxyNetwork) DialContext(ctx context.Context, network, address string) (essentials.Conn, error) {
|
||||
conn, err := p.client.DialContext(ctx, network, address)
|
||||
if err != nil {
|
||||
@@ -24,6 +29,16 @@ func (p proxyNetwork) DialContext(ctx context.Context, network, address string)
|
||||
return essentials.WrapNetConn(conn), nil
|
||||
}
|
||||
|
||||
func (p proxyNetwork) MakeHTTPClient(
|
||||
dialFunc func(context.Context, string, string) (essentials.Conn, error),
|
||||
) *http.Client {
|
||||
if dialFunc == nil {
|
||||
dialFunc = p.DialContext
|
||||
}
|
||||
|
||||
return p.Network.MakeHTTPClient(dialFunc)
|
||||
}
|
||||
|
||||
func NewProxyNetwork(base mtglib.Network, proxyURL *url.URL) (*proxyNetwork, error) {
|
||||
socks, err := proxy.FromURL(proxyURL, base.NativeDialer())
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user