mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2026-01-09 07:59:00 +08:00
Some checks are pending
Test / test (1.20, macos-15-intel) (push) Waiting to run
Test / test (1.20, macos-latest) (push) Waiting to run
Test / test (1.20, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.20, ubuntu-latest) (push) Waiting to run
Test / test (1.20, windows-latest) (push) Waiting to run
Test / test (1.21, macos-15-intel) (push) Waiting to run
Test / test (1.21, macos-latest) (push) Waiting to run
Test / test (1.21, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.21, ubuntu-latest) (push) Waiting to run
Test / test (1.21, windows-latest) (push) Waiting to run
Test / test (1.22, macos-15-intel) (push) Waiting to run
Test / test (1.22, macos-latest) (push) Waiting to run
Test / test (1.22, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.22, ubuntu-latest) (push) Waiting to run
Test / test (1.22, windows-latest) (push) Waiting to run
Test / test (1.23, macos-15-intel) (push) Waiting to run
Test / test (1.23, macos-latest) (push) Waiting to run
Test / test (1.23, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.23, ubuntu-latest) (push) Waiting to run
Test / test (1.23, windows-latest) (push) Waiting to run
Test / test (1.24, macos-15-intel) (push) Waiting to run
Test / test (1.24, macos-latest) (push) Waiting to run
Test / test (1.24, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.24, ubuntu-latest) (push) Waiting to run
Test / test (1.24, windows-latest) (push) Waiting to run
Test / test (1.25, macos-15-intel) (push) Waiting to run
Test / test (1.25, macos-latest) (push) Waiting to run
Test / test (1.25, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.25, ubuntu-latest) (push) Waiting to run
Test / test (1.25, windows-latest) (push) Waiting to run
Test / test (1.26.0-rc.1, macos-15-intel) (push) Waiting to run
Test / test (1.26.0-rc.1, macos-latest) (push) Waiting to run
Test / test (1.26.0-rc.1, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.26.0-rc.1, ubuntu-latest) (push) Waiting to run
Test / test (1.26.0-rc.1, windows-latest) (push) Waiting to run
Trigger CMFA Update / trigger-CMFA-update (push) Waiting to run
57 lines
944 B
Go
57 lines
944 B
Go
package common
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
C "github.com/metacubex/mihomo/constant"
|
|
)
|
|
|
|
type InUser struct {
|
|
Base
|
|
users []string
|
|
adapter string
|
|
payload string
|
|
}
|
|
|
|
func (u *InUser) Match(metadata *C.Metadata, helper C.RuleMatchHelper) (bool, string) {
|
|
for _, user := range u.users {
|
|
if metadata.InUser == user {
|
|
return true, u.adapter
|
|
}
|
|
}
|
|
return false, ""
|
|
}
|
|
|
|
func (u *InUser) RuleType() C.RuleType {
|
|
return C.InUser
|
|
}
|
|
|
|
func (u *InUser) Adapter() string {
|
|
return u.adapter
|
|
}
|
|
|
|
func (u *InUser) Payload() string {
|
|
return u.payload
|
|
}
|
|
|
|
func NewInUser(iUsers, adapter string) (*InUser, error) {
|
|
users := strings.Split(iUsers, "/")
|
|
for i, user := range users {
|
|
user = strings.TrimSpace(user)
|
|
if len(user) == 0 {
|
|
return nil, fmt.Errorf("in user couldn't be empty")
|
|
}
|
|
users[i] = user
|
|
}
|
|
|
|
return &InUser{
|
|
Base: Base{},
|
|
users: users,
|
|
adapter: adapter,
|
|
payload: iUsers,
|
|
}, nil
|
|
}
|
|
|
|
var _ C.Rule = (*InUser)(nil)
|