[Fixed]尝试修复PASS空指针问题
[Chore]调整workflows测试
This commit is contained in:
parent
64a5fd02da
commit
ffff1418f2
5 changed files with 24 additions and 103 deletions
14
.github/workflows/Alpha.yml
vendored
14
.github/workflows/Alpha.yml
vendored
|
@ -34,10 +34,20 @@ jobs:
|
|||
BINDIR: bin
|
||||
run: make -j releases
|
||||
|
||||
- uses: dev-drprasad/delete-tag-and-release@v0.2.0
|
||||
with:
|
||||
delete_release: true # default: false
|
||||
tag_name: alpha # tag name to delete
|
||||
repo: <owner>/<repoName> # target repo (optional). defaults to repo running this action
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Upload Alpha
|
||||
uses: softprops/action-gh-release@v1
|
||||
uses: svenstaro/upload-release-action@v2
|
||||
if: ${{ env.GIT_BRANCH != 'Meta' && success() }}
|
||||
with:
|
||||
tag_name: alpha
|
||||
tag: ${{ github.ref }}
|
||||
asset_name: alpha
|
||||
overwrite: true
|
||||
files: bin/*
|
||||
prerelease: true
|
|
@ -56,3 +56,13 @@ func NewCompatible() *Direct {
|
|||
},
|
||||
}
|
||||
}
|
||||
|
||||
func NewPass() *Direct {
|
||||
return &Direct{
|
||||
Base: &Base{
|
||||
name: "Pass",
|
||||
tp: C.Pass,
|
||||
udp: true,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
package outbound
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"github.com/Dreamacro/clash/component/dialer"
|
||||
|
||||
C "github.com/Dreamacro/clash/constant"
|
||||
)
|
||||
|
||||
type Pass struct {
|
||||
*Base
|
||||
}
|
||||
|
||||
// DialContext implements C.ProxyAdapter
|
||||
func (r *Pass) DialContext(ctx context.Context, metadata *C.Metadata, opts ...dialer.Option) (C.Conn, error) {
|
||||
return nil, errors.New("match Pass rule")
|
||||
}
|
||||
|
||||
// ListenPacketContext implements C.ProxyAdapter
|
||||
func (r *Pass) ListenPacketContext(ctx context.Context, metadata *C.Metadata, opts ...dialer.Option) (C.PacketConn, error) {
|
||||
return nil, errors.New("match Pass rule")
|
||||
}
|
||||
|
||||
func NewPass() *Pass {
|
||||
return &Pass{
|
||||
Base: &Base{
|
||||
name: "PASS",
|
||||
tp: C.Pass,
|
||||
udp: true,
|
||||
},
|
||||
}
|
||||
}
|
|
@ -10,7 +10,6 @@ import (
|
|||
"net/netip"
|
||||
"net/url"
|
||||
"os"
|
||||
"regexp"
|
||||
"runtime"
|
||||
"strings"
|
||||
"time"
|
||||
|
@ -210,7 +209,6 @@ type RawConfig struct {
|
|||
Proxy []map[string]any `yaml:"proxies"`
|
||||
ProxyGroup []map[string]any `yaml:"proxy-groups"`
|
||||
Rule []string `yaml:"rules"`
|
||||
Script Script `yaml:"script"`
|
||||
}
|
||||
|
||||
// Parse config
|
||||
|
@ -280,10 +278,6 @@ func UnmarshalRawConfig(buf []byte) (*RawConfig, error) {
|
|||
Profile: Profile{
|
||||
StoreSelected: true,
|
||||
},
|
||||
Script: Script{
|
||||
MainCode: "",
|
||||
ShortcutsCode: map[string]string{},
|
||||
},
|
||||
}
|
||||
|
||||
if err := yaml.Unmarshal(buf, rawCfg); err != nil {
|
||||
|
@ -322,11 +316,6 @@ func ParseRawConfig(rawCfg *RawConfig) (*Config, error) {
|
|||
config.Proxies = proxies
|
||||
config.Providers = providers
|
||||
|
||||
err = parseScript(rawCfg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rules, ruleProviders, err := parseRules(rawCfg, proxies)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -494,49 +483,6 @@ func parseProxies(cfg *RawConfig) (proxies map[string]C.Proxy, providersMap map[
|
|||
return proxies, providersMap, nil
|
||||
}
|
||||
|
||||
func parseScript(cfg *RawConfig) error {
|
||||
mode := cfg.Mode
|
||||
script := cfg.Script
|
||||
mainCode := cleanPyKeywords(script.MainCode)
|
||||
shortcutsCode := script.ShortcutsCode
|
||||
|
||||
if mode != T.Script && len(shortcutsCode) == 0 {
|
||||
return nil
|
||||
} else if mode == T.Script && len(mainCode) == 0 {
|
||||
return fmt.Errorf("initialized script module failure, can't find script code in the config file")
|
||||
}
|
||||
|
||||
content :=
|
||||
`# -*- coding: UTF-8 -*-
|
||||
|
||||
from datetime import datetime as whatever
|
||||
|
||||
class ClashTime:
|
||||
def now(self):
|
||||
return whatever.now()
|
||||
|
||||
def unix(self):
|
||||
return int(whatever.now().timestamp())
|
||||
|
||||
def unix_nano(self):
|
||||
return int(round(whatever.now().timestamp() * 1000))
|
||||
|
||||
time = ClashTime()
|
||||
|
||||
`
|
||||
for k, v := range shortcutsCode {
|
||||
v = cleanPyKeywords(v)
|
||||
v = strings.TrimSpace(v)
|
||||
if len(v) == 0 {
|
||||
return fmt.Errorf("initialized rule SCRIPT failure, shortcut [%s] code invalid syntax", k)
|
||||
}
|
||||
|
||||
content += "def " + strings.ToLower(k) + "(ctx, network, process_name, host, src_ip, src_port, dst_ip, dst_port):\n return " + v + "\n\n"
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func parseRules(cfg *RawConfig, proxies map[string]C.Proxy) ([]C.Rule, map[string]*providerTypes.RuleProvider, error) {
|
||||
ruleProviders := map[string]*providerTypes.RuleProvider{}
|
||||
log.Infoln("Geodata Loader mode: %s", geodata.LoaderName())
|
||||
|
@ -887,7 +833,7 @@ func parseDNS(rawCfg *RawConfig, hosts *trie.DomainTrie, rules []C.Rule) (*DNS,
|
|||
}
|
||||
|
||||
func parseAuthentication(rawRecords []string) []auth.AuthUser {
|
||||
users := []auth.AuthUser{}
|
||||
var users []auth.AuthUser
|
||||
for _, line := range rawRecords {
|
||||
if user, pass, found := strings.Cut(line, ":"); found {
|
||||
users = append(users, auth.AuthUser{User: user, Pass: pass})
|
||||
|
@ -896,19 +842,6 @@ func parseAuthentication(rawRecords []string) []auth.AuthUser {
|
|||
return users
|
||||
}
|
||||
|
||||
func cleanPyKeywords(code string) string {
|
||||
if len(code) == 0 {
|
||||
return code
|
||||
}
|
||||
keywords := []string{"import", "print"}
|
||||
|
||||
for _, kw := range keywords {
|
||||
reg := regexp.MustCompile("(?m)[\r\n]+^.*" + kw + ".*$")
|
||||
code = reg.ReplaceAllString(code, "")
|
||||
}
|
||||
return code
|
||||
}
|
||||
|
||||
func parseTun(rawTun RawTun, general *General) (*Tun, error) {
|
||||
if (rawTun.Enable || general.TProxyPort != 0) && general.Interface == "" {
|
||||
autoDetectInterfaceName, err := commons.GetAutoDetectInterface()
|
||||
|
|
|
@ -369,6 +369,7 @@ func match(metadata *C.Metadata) (C.Proxy, C.Rule, error) {
|
|||
}
|
||||
|
||||
if adapter.Type() == C.Pass || (adapter.Unwrap(metadata) != nil && adapter.Unwrap(metadata).Type() == C.Pass) {
|
||||
log.Debugln("%s match Pass rule", adapter.Name())
|
||||
continue
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue