mirror of
https://github.com/MetaCubeX/Clash.Meta.git
synced 2025-04-19 16:50:56 +00:00
Merge branch 'MetaCubeX:Alpha' into Alpha
This commit is contained in:
commit
4b401ab1d3
12 changed files with 62 additions and 16 deletions
8
.github/genReleaseNote.sh
vendored
8
.github/genReleaseNote.sh
vendored
|
@ -18,15 +18,15 @@ if [ -z "$version_range" ]; then
|
|||
fi
|
||||
|
||||
echo "## What's Changed" > release.md
|
||||
git log --pretty=format:"* %s by @%an" --grep="^feat" -i $version_range | sort -f | uniq >> release.md
|
||||
git log --pretty=format:"* %h %s by @%an" --grep="^feat" -i $version_range | sort -f | uniq >> release.md
|
||||
echo "" >> release.md
|
||||
|
||||
echo "## BUG & Fix" >> release.md
|
||||
git log --pretty=format:"* %s by @%an" --grep="^fix" -i $version_range | sort -f | uniq >> release.md
|
||||
git log --pretty=format:"* %h %s by @%an" --grep="^fix" -i $version_range | sort -f | uniq >> release.md
|
||||
echo "" >> release.md
|
||||
|
||||
echo "## Maintenance" >> release.md
|
||||
git log --pretty=format:"* %s by @%an" --grep="^chore\|^docs\|^refactor" -i $version_range | sort -f | uniq >> release.md
|
||||
git log --pretty=format:"* %h %s by @%an" --grep="^chore\|^docs\|^refactor" -i $version_range | sort -f | uniq >> release.md
|
||||
echo "" >> release.md
|
||||
|
||||
echo "**Full Changelog**: https://github.com/MetaCubeX/Clash.Meta/compare/$version_range" >> release.md
|
||||
echo "**Full Changelog**: https://github.com/MetaCubeX/mihomo/compare/$version_range" >> release.md
|
||||
|
|
6
.github/workflows/build.yml
vendored
6
.github/workflows/build.yml
vendored
|
@ -141,6 +141,12 @@ jobs:
|
|||
run: |
|
||||
go test ./...
|
||||
|
||||
- name: Update UA
|
||||
run: |
|
||||
sudo apt-get install ca-certificates
|
||||
sudo update-ca-certificates
|
||||
cp -f /etc/ssl/certs/ca-certificates.crt component/ca/ca-certificates.crt
|
||||
|
||||
- name: Build core
|
||||
env:
|
||||
GOOS: ${{matrix.jobs.goos}}
|
||||
|
|
0
component/ca/ca-certificates.crt
Normal file
0
component/ca/ca-certificates.crt
Normal file
|
@ -5,10 +5,12 @@ import (
|
|||
"crypto/sha256"
|
||||
"crypto/tls"
|
||||
"crypto/x509"
|
||||
_ "embed"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
)
|
||||
|
@ -18,6 +20,11 @@ var globalCertPool *x509.CertPool
|
|||
var mutex sync.RWMutex
|
||||
var errNotMatch = errors.New("certificate fingerprints do not match")
|
||||
|
||||
//go:embed ca-certificates.crt
|
||||
var _CaCertificates []byte
|
||||
var DisableEmbedCa, _ = strconv.ParseBool(os.Getenv("DISABLE_EMBED_CA"))
|
||||
var DisableSystemCa, _ = strconv.ParseBool(os.Getenv("DISABLE_SYSTEM_CA"))
|
||||
|
||||
func AddCertificate(certificate string) error {
|
||||
mutex.Lock()
|
||||
defer mutex.Unlock()
|
||||
|
@ -34,13 +41,20 @@ func AddCertificate(certificate string) error {
|
|||
|
||||
func initializeCertPool() {
|
||||
var err error
|
||||
globalCertPool, err = x509.SystemCertPool()
|
||||
if err != nil {
|
||||
if DisableSystemCa {
|
||||
globalCertPool = x509.NewCertPool()
|
||||
} else {
|
||||
globalCertPool, err = x509.SystemCertPool()
|
||||
if err != nil {
|
||||
globalCertPool = x509.NewCertPool()
|
||||
}
|
||||
}
|
||||
for _, cert := range trustCerts {
|
||||
globalCertPool.AddCert(cert)
|
||||
}
|
||||
if !DisableEmbedCa {
|
||||
globalCertPool.AppendCertsFromPEM(_CaCertificates)
|
||||
}
|
||||
}
|
||||
|
||||
func ResetCertificate() {
|
||||
|
|
|
@ -40,16 +40,23 @@ func ResolveInterface(name string) (*Interface, error) {
|
|||
|
||||
ipNets := make([]netip.Prefix, 0, len(addrs))
|
||||
for _, addr := range addrs {
|
||||
ipNet := addr.(*net.IPNet)
|
||||
ip, _ := netip.AddrFromSlice(ipNet.IP)
|
||||
|
||||
ones, bits := ipNet.Mask.Size()
|
||||
if bits == 32 {
|
||||
var pf netip.Prefix
|
||||
switch ipNet := addr.(type) {
|
||||
case *net.IPNet:
|
||||
ip, _ := netip.AddrFromSlice(ipNet.IP)
|
||||
ones, bits := ipNet.Mask.Size()
|
||||
if bits == 32 {
|
||||
ip = ip.Unmap()
|
||||
}
|
||||
pf = netip.PrefixFrom(ip, ones)
|
||||
case *net.IPAddr:
|
||||
ip, _ := netip.AddrFromSlice(ipNet.IP)
|
||||
ip = ip.Unmap()
|
||||
pf = netip.PrefixFrom(ip, ip.BitLen())
|
||||
}
|
||||
if pf.IsValid() {
|
||||
ipNets = append(ipNets, pf)
|
||||
}
|
||||
|
||||
pf := netip.PrefixFrom(ip, ones)
|
||||
ipNets = append(ipNets, pf)
|
||||
}
|
||||
|
||||
r[iface.Name] = &Interface{
|
||||
|
|
|
@ -265,6 +265,7 @@ type RawTun struct {
|
|||
EndpointIndependentNat bool `yaml:"endpoint-independent-nat" json:"endpoint_independent_nat,omitempty"`
|
||||
UDPTimeout int64 `yaml:"udp-timeout" json:"udp_timeout,omitempty"`
|
||||
FileDescriptor int `yaml:"file-descriptor" json:"file-descriptor"`
|
||||
TableIndex int `yaml:"table-index" json:"table-index"`
|
||||
}
|
||||
|
||||
type RawTuicServer struct {
|
||||
|
@ -1448,6 +1449,7 @@ func parseTun(rawTun RawTun, general *General) error {
|
|||
EndpointIndependentNat: rawTun.EndpointIndependentNat,
|
||||
UDPTimeout: rawTun.UDPTimeout,
|
||||
FileDescriptor: rawTun.FileDescriptor,
|
||||
TableIndex: rawTun.TableIndex,
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
@ -91,6 +91,7 @@ type tunSchema struct {
|
|||
EndpointIndependentNat *bool `yaml:"endpoint-independent-nat" json:"endpoint-independent-nat,omitempty"`
|
||||
UDPTimeout *int64 `yaml:"udp-timeout" json:"udp-timeout,omitempty"`
|
||||
FileDescriptor *int `yaml:"file-descriptor" json:"file-descriptor"`
|
||||
TableIndex *int `yaml:"table-index" json:"table-index"`
|
||||
}
|
||||
|
||||
type tuicServerSchema struct {
|
||||
|
@ -209,6 +210,9 @@ func pointerOrDefaultTun(p *tunSchema, def LC.Tun) LC.Tun {
|
|||
if p.FileDescriptor != nil {
|
||||
def.FileDescriptor = *p.FileDescriptor
|
||||
}
|
||||
if p.TableIndex != nil {
|
||||
def.TableIndex = *p.TableIndex
|
||||
}
|
||||
}
|
||||
return def
|
||||
}
|
||||
|
|
|
@ -49,4 +49,5 @@ type Tun struct {
|
|||
EndpointIndependentNat bool `yaml:"endpoint-independent-nat" json:"endpoint-independent-nat,omitempty"`
|
||||
UDPTimeout int64 `yaml:"udp-timeout" json:"udp-timeout,omitempty"`
|
||||
FileDescriptor int `yaml:"file-descriptor" json:"file-descriptor"`
|
||||
TableIndex int `yaml:"table-index" json:"table-index"`
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ type TunOption struct {
|
|||
EndpointIndependentNat bool `inbound:"endpoint_independent_nat,omitempty"`
|
||||
UDPTimeout int64 `inbound:"udp_timeout,omitempty"`
|
||||
FileDescriptor int `inbound:"file-descriptor,omitempty"`
|
||||
TableIndex int `inbound:"table-index,omitempty"`
|
||||
}
|
||||
|
||||
func (o TunOption) Equal(config C.InboundConfig) bool {
|
||||
|
@ -118,6 +119,7 @@ func NewTun(options *TunOption) (*Tun, error) {
|
|||
EndpointIndependentNat: options.EndpointIndependentNat,
|
||||
UDPTimeout: options.UDPTimeout,
|
||||
FileDescriptor: options.FileDescriptor,
|
||||
TableIndex: options.TableIndex,
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
|
|
@ -823,7 +823,8 @@ func hasTunConfigChange(tunConf *LC.Tun) bool {
|
|||
LastTunConf.StrictRoute != tunConf.StrictRoute ||
|
||||
LastTunConf.EndpointIndependentNat != tunConf.EndpointIndependentNat ||
|
||||
LastTunConf.UDPTimeout != tunConf.UDPTimeout ||
|
||||
LastTunConf.FileDescriptor != tunConf.FileDescriptor {
|
||||
LastTunConf.FileDescriptor != tunConf.FileDescriptor ||
|
||||
LastTunConf.TableIndex != tunConf.TableIndex {
|
||||
return true
|
||||
}
|
||||
|
||||
|
|
|
@ -112,6 +112,10 @@ func New(options LC.Tun, tunnel C.Tunnel, additions ...inbound.Addition) (l *Lis
|
|||
} else {
|
||||
udpTimeout = int64(sing.UDPTimeout.Seconds())
|
||||
}
|
||||
tableIndex := options.TableIndex
|
||||
if tableIndex == 0 {
|
||||
tableIndex = 2022
|
||||
}
|
||||
includeUID := uidToRange(options.IncludeUID)
|
||||
if len(options.IncludeUIDRange) > 0 {
|
||||
var err error
|
||||
|
@ -225,7 +229,7 @@ func New(options LC.Tun, tunnel C.Tunnel, additions ...inbound.Addition) (l *Lis
|
|||
ExcludePackage: options.ExcludePackage,
|
||||
FileDescriptor: options.FileDescriptor,
|
||||
InterfaceMonitor: defaultInterfaceMonitor,
|
||||
TableIndex: 2022,
|
||||
TableIndex: tableIndex,
|
||||
}
|
||||
|
||||
err = l.buildAndroidRules(&tunOptions)
|
||||
|
|
|
@ -3,6 +3,7 @@ package vmess
|
|||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
|
@ -54,6 +55,10 @@ func (hc *httpConn) Write(b []byte) (int, error) {
|
|||
return hc.Conn.Write(b)
|
||||
}
|
||||
|
||||
if len(hc.cfg.Path) == 0 {
|
||||
return -1, errors.New("path is empty")
|
||||
}
|
||||
|
||||
path := hc.cfg.Path[fastrand.Intn(len(hc.cfg.Path))]
|
||||
host := hc.cfg.Host
|
||||
if header := hc.cfg.Headers["Host"]; len(header) != 0 {
|
||||
|
|
Loading…
Add table
Reference in a new issue