Marzban icon indicating copy to clipboard operation
Marzban copied to clipboard

some fix and small features

Open M03ED opened this issue 9 months ago • 11 comments

fix:

  • report change status temporary #845
  • accept unix domain #931
  • days left for expired users #903
  • fragment field in streisand #924 #827
  • early data for clash #896
  • kcp for v2ray json
  • quic for v2ray json #886

feat:

  • add spiderx #957
  • add multi mode for grpc #885 #641
  • add json config for v2rayn #659

refactor:

  • V2rayShareLink class usage
  • remove external if else in share.py

M03ED avatar Apr 28 '24 17:04 M03ED

gRPC is changes in latest versions of Xray-core, check this : https://github.com/XTLS/Xray-core/pull/1815

There is 3 different type of gRPC server configs : gRPC Gun (Supported on all clients) gRPC Multi (Supported only on Xray-core based clients) gRPC 2 in 1 Inbound: Both types in 1 inbound with Custom Path, for this one Marzban should parse Inbound's serviceName and use Multi for Xray based clients, and Gun for other clients

And network name for gRPC can be 'grpc' or 'gun' other network names have aliases too. check this : https://github.com/XTLS/Xray-core/blob/51504c624c4aa9c093cf607cfca16e9548743af0/infra/conf/transport_internet.go#L631

fodhelper avatar Apr 29 '24 15:04 fodhelper

gRPC is changes in latest versions of Xray-core, check this : XTLS/Xray-core#1815

ok so we can have this type of grpc with "network": "grpc" or have normal grpc with "network": "gun" right ?

M03ED avatar Apr 29 '24 17:04 M03ED

network 'gun' and network 'grpc' are same thing, one transport with multiple aliases

fodhelper avatar Apr 29 '24 20:04 fodhelper

gRPC is changes in latest versions of Xray-core, check this : XTLS/Xray-core#1815

There is 3 different type of gRPC server configs : gRPC Gun (Supported on all clients) gRPC Multi (Supported only on Xray-core based clients) gRPC 2 in 1 Inbound: Both types in 1 inbound with Custom Path, for this one Marzban should parse Inbound's serviceName and use Multi for Xray based clients, and Gun for other clients

And network name for gRPC can be 'grpc' or 'gun' other network names have aliases too. check this : https://github.com/XTLS/Xray-core/blob/51504c624c4aa9c093cf607cfca16e9548743af0/infra/conf/transport_internet.go#L631

done.

M03ED avatar Apr 30 '24 11:04 M03ED

Please revert "feat: support gRPC Custom Path", it's wrong

We must check if path is started with "/" or not If it's not started with "/" then we must send path like before to all clients

But if it's started with "/" we must split it in serviceName and streamName(Gun) and streamName(Multi) Example path = "/custom/path/GunCustomPath|MultiCustomPath" serviceName = custom/path streamName(Gun) = GunCustomPath streamName(Multi) = MultiCustomPath

now for Xray based clients we must send the full path ("/custom/path/GunCustomPath|MultiCustomPath") in sharelink, this path must get urlEncoded https://github.com/XTLS/Xray-core/releases/tag/v1.8.9 But for v2ray json config i think there is no need to urlEncode the path (must test it)

And when user uses this type of Path for gRPC, it does not mean MultiMode is Enabled, it could be disabled This type of path only means we use custom streamName

For Clash.Meta and Sing-Box Gun mode will only work if streamName(Gun) is euqal to "Tun" And we must send path to them like old type of configs (without the first "/" and without /streamName)

fodhelper avatar Apr 30 '24 16:04 fodhelper

You can add randomUserAgent function to the new function file

import random

# Source: https://cdn.jsdelivr.net/gh/microlinkhq/top-user-agents@master/src/index.json
UserAgentList = [
  "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36",
  "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36",
  "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36"
]

def genRandUserAgent():
  return random.choice(UserAgentList)

print(genRandUserAgent())

You can add all 100 user agents from the url and update user agent list later too, but making many requests to jsdelivr cdn is not good, they may have or add a rate limit or block our server's ip

gRPC supports custom user-agent too, with user agent and authority of grpc we can use it with no tls and remain undetected

fodhelper avatar Apr 30 '24 22:04 fodhelper

Please revert "feat: support gRPC Custom Path", it's wrong

We must check if path is started with "/" or not If it's not started with "/" then we must send path like before to all clients

But if it's started with "/" we must split it in serviceName and streamName(Gun) and streamName(Multi) Example path = "/custom/path/GunCustomPath|MultiCustomPath" serviceName = custom/path streamName(Gun) = GunCustomPath streamName(Multi) = MultiCustomPath

now for Xray based clients we must send the full path ("/custom/path/GunCustomPath|MultiCustomPath") in sharelink, this path must get urlEncoded https://github.com/XTLS/Xray-core/releases/tag/v1.8.9 But for v2ray json config i think there is no need to urlEncode the path (must test it)

And when user uses this type of Path for gRPC, it does not mean MultiMode is Enabled, it could be disabled This type of path only means we use custom streamName

For Clash.Meta and Sing-Box Gun mode will only work if streamName(Gun) is euqal to "Tun" And we must send path to them like old type of configs (without the first "/" and without /streamName)

this is what they provide as a sample

server side :

"serviceName": "/my/sample/path/customTun|customTunMulti"

client without multi:

"serviceName": "/my/sample/path/customTun",
"multiMode": false

client with multi tun:

"serviceName": "/my/sample/path/customTunMulti",
"multiMode": true

if you don't want to use multi mode without conflict with not xray based client you can just use normal grpc we already sending path like before , only thing we do its separating grpc path for xray based clients and other ones but i cant change that custom to be really custom

i'm not sure what you what you mean by urlEncode , we have different type of that

M03ED avatar May 03 '24 22:05 M03ED

but i cant change that custom to be really custom

check this :

def get_grpc_gun(input: str):
    if not input.startswith("/"):
        return input
    
    servicename = input.rsplit("/", 1)[0]
    streamname = input.rsplit("/", 1)[1].split("|")[0]
    
    if streamname == "Tun":
        return servicename[1:]
    
    return "%s%s%s" % (servicename, "/", streamname)

def get_grpc_multi(input: str):
    if not input.startswith("/"):
        return input
    
    servicename = input.rsplit("/", 1)[0]
    streamname = input.rsplit("/", 1)[1].split("|")[1]

    return "%s%s%s" % (servicename, "/", streamname)

print(get_grpc_gun("oldPath"))
print(get_grpc_gun("/newPath/Tun|MultiCustomPath"))
print(get_grpc_gun("/new/path/GunCustomPath|MultiCustomPath"))

print(get_grpc_multi("oldPath"))
print(get_grpc_multi("/new/path/GunCustomPath|MultiCustomPath"))

i'm not sure what you what you mean by urlEncode , we have different type of that

In xray-core tag 1.8.9 written encodeURIComponent https://github.com/XTLS/Xray-core/releases/tag/v1.8.9 https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent so it must be

from urllib.parse import quote

print(quote("/my/path", safe="-_.!~*'()"))

fodhelper avatar May 04 '24 05:05 fodhelper

so for not xray based clients we use get_grpc_gun and for xray based if multimode was enable we use get_grpc_multi?

M03ED avatar May 04 '24 09:05 M03ED

and i can't find any user agent option for grpc

M03ED avatar May 04 '24 09:05 M03ED

so for not xray based clients we use get_grpc_gun and for xray based if multimode was enable we use get_grpc_multi?

exactly If multiMode is disabled >> get_grpc_gun (for all clients) if multiMode is enabled >> get_grpc_multi (for xray based clients) and get_grpc_gun (for other clients)

and i can't find any user agent option for grpc

They added it in https://github.com/XTLS/Xray-core/pull/1790/files But they didn't added it in docs because it's useless! as no browser uses gRPC so using a user-agent of browser is useless no *ray client supports it too, so we must leave it for now

fodhelper avatar May 04 '24 22:05 fodhelper

i fix grpc and add encode for service name start with /

M03ED avatar May 30 '24 11:05 M03ED

@SaintShit

M03ED avatar Jun 07 '24 14:06 M03ED

thank you all great

SaintShit avatar Jul 01 '24 14:07 SaintShit