Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added functionality to edit/add fragment to configs #2832

Closed
wants to merge 11 commits into from

Conversation

vfarid
Copy link
Contributor

@vfarid vfarid commented Feb 10, 2024

Added functionality to config editor interface and make it poosible to add/edit fragment setting using UI:

photo_2024-02-11_00-34-36

@tahadm
Copy link

tahadm commented Feb 10, 2024

It will be realy useful for users

@NIKJOO
Copy link

NIKJOO commented Feb 10, 2024

It could make v2rayN so flexible to modify configs as easiest way as possible

@2dust
Copy link
Owner

2dust commented Feb 11, 2024

https://xtls.github.io/config/outbounds/freedom.html#outboundconfigurationobject
XTLS/Xray-core#2392

fragment can only be used with freedom
This pr makes no sense

@2dust
Copy link
Owner

2dust commented Feb 11, 2024

You can customize the configuration using fragment

@lowercase78
Copy link

Most of users can't edit config and use fragments,

It's easier if able to set it frome ui🙏

@vfarid
Copy link
Contributor Author

vfarid commented Feb 11, 2024

Yep, i will fix it.

…nfigs

- Added `outboundFragmentBean` property to `ServerConfig` in order to fix previous fault and have fragment as freedom protocol in outbounds array and all its consequences.
- Added `fragment` property to vless/vmess config str for both import and share actions.
@vfarid
Copy link
Contributor Author

vfarid commented Feb 11, 2024

I did some changes to fix my previous fault (moving fragment to freedom protocol) and added possibility to import/share fragment in configs.

@AliM1988
Copy link

AliM1988 commented Feb 11, 2024

@vfarid
I suggest support fragment and mux into uri config. I see some iOS clients (Streisand) support it like as:

vless://123456789987654@discord.com:8443?type=ws&host=jd-vpn.shop&path=/&security=tls&fp=chrome&sni=Fre
Jd-Vpn.shop&alpn=h2,http/1.1&fragment=20-40,5-10,tlshello&mux=8#test

It would be good to be a compatibility across all clients.

@vfarid
Copy link
Contributor Author

vfarid commented Feb 11, 2024

I added this feature as well but the order is different. Since the main i tem is packet and then lenght, i ordered them like "packets,length,interval". I dont have any idea what app you are referring to which accept fragment in configs, but i think this is the right order.
Anyway, if not, the team can change it during the merge.

@AliM1988
Copy link

AliM1988 commented Feb 11, 2024

@vfarid I will check. Also please add Mux. There are 3 parameters for Mux.

"mux": {
                "enabled": true,
                "concurrency": 8,
                "xudpConcurrency": 8,
                "xudpProxyUDP443": "reject"

@AliM1988
Copy link

AliM1988 commented Feb 11, 2024

I added this feature as well but the order is different. Since the main i tem is packet and then lenght, i ordered them like "packets,length,interval". I dont have any idea what app you are referring to which accept fragment in configs, but i think this is the right order. Anyway, if not, the team can change it during the merge.

I checked again in Streisand, in exported config the order is: "length,interval,packets" and supports Mux (1 parameter only).
I tested 2 below configs (Striesand's order and Yours). Both of them work!

vless://123456789987654@discord.com:8443?type=ws&host=jd-vpn.shop&path=/&security=tls&fp=chrome&sni=Fre
Jd-Vpn.shop&alpn=h2,http/1.1&fragment=20-40,5-10,tlshello&mux=8#test1

vless://123456789987654@discord.com:8443?type=ws&host=jd-vpn.shop&path=/&security=tls&fp=chrome&sni=Fre
Jd-Vpn.shop&alpn=h2,http/1.1&fragment=tlshello,20-40,5-10&mux=8#test2

So, Striesand accepts both and itself handles the order of parameters.

@vfarid
Copy link
Contributor Author

vfarid commented Feb 11, 2024

@2dust please take a look at new commits on my pr, i fixed what you said about freedom protocol and added fragment to configs str as well.
Here is sample of vless config edited in ui with fragment, both url and custom config exported by my compiled version:

vless://ebc4a168-a6fe-47ce-bc25-6183c6212dcc@104.17.138.140:2096?path=vless-ws%2F%3Fed%3D2048&security=tls&fragment=tlshello,10-20,10-20&encryption=none&alpn=h2&host=sub.vfarid.workeRS.dEv&fp=ios&type=ws&sni=sub.vfarid.workeRS.dEv#1-vless-worker-104.17.138.140
{
  "dns": {
    "hosts": {
      "domain:googleapis.cn": "googleapis.com"
    },
    "servers": [
      "1.1.1.1"
    ]
  },
  "inbounds": [
    {
      "listen": "127.0.0.1",
      "port": 10808,
      "protocol": "socks",
      "settings": {
        "auth": "noauth",
        "udp": true,
        "userLevel": 8
      },
      "sniffing": {
        "destOverride": [
          "http",
          "tls"
        ],
        "enabled": true
      },
      "tag": "socks"
    },
    {
      "listen": "127.0.0.1",
      "port": 10809,
      "protocol": "http",
      "settings": {
        "userLevel": 8
      },
      "tag": "http"
    }
  ],
  "log": {
    "loglevel": "warning"
  },
  "outbounds": [
    {
      "mux": {
        "concurrency": -1,
        "enabled": false,
        "xudpConcurrency": 8,
        "xudpProxyUDP443": ""
      },
      "protocol": "vless",
      "settings": {
        "vnext": [
          {
            "address": "104.17.138.140",
            "port": 2096,
            "users": [
              {
                "encryption": "none",
                "flow": "",
                "id": "ebc4a168-a6fe-47ce-bc25-6183c6212dcc",
                "level": 8,
                "security": "auto"
              }
            ]
          }
        ]
      },
      "streamSettings": {
        "network": "ws",
        "security": "tls",
        "tlsSettings": {
          "allowInsecure": false,
          "alpn": [
            "h2"
          ],
          "fingerprint": "ios",
          "publicKey": "",
          "serverName": "sub.vfarid.workeRS.dEv",
          "shortId": "",
          "show": false,
          "spiderX": ""
        },
        "wsSettings": {
          "headers": {
            "Host": "sub.vfarid.workeRS.dEv"
          },
          "path": "vless-ws/?ed=2048"
        }
      },
      "tag": "proxy"
    },
    {
      "mux": {
        "concurrency": 8,
        "enabled": false,
        "xudpConcurrency": 8,
        "xudpProxyUDP443": ""
      },
      "protocol": "freedom",
      "settings": {
        "fragment": {
          "interval": "10-20",
          "length": "10-20",
          "packets": "tlshello"
        }
      },
      "tag": "fragment"
    },
    {
      "protocol": "blackhole",
      "settings": {
        "response": {
          "type": "http"
        }
      },
      "tag": "block"
    }
  ],
  "routing": {
    "domainStrategy": "IPIfNonMatch",
    "rules": [
      {
        "ip": [
          "1.1.1.1"
        ],
        "outboundTag": "proxy",
        "port": "53",
        "type": "field"
      }
    ]
  }
}

@AliM1988
Copy link

@vfarid Please add mux as well. In some cases without mux, fragment doesn't work properly.

@vfarid
Copy link
Contributor Author

vfarid commented Feb 11, 2024

Mux is already implemented as a global setting.

@AliM1988
Copy link

@vfarid Yes, I know it. But cant be controlled via subscription. And it isn't good to enable Mux totally instead of a specific config.

@2dust
Copy link
Owner

2dust commented Feb 12, 2024

XTLS/Xray-core#2392


{
  "log": {
    "loglevel": "debug",
    "dnsLog": false
  },
  "inbounds": [
    {
      "listen": "127.0.0.1",
      "port": 10808,
      "protocol": "socks",
      "tag": "socks"
    }
  ],
  "outbounds": [
    {
      "tag": "proxy",
      "protocol": "VLESS",
      "settings": {},
      "streamSettings": {
        "network": "ws",
        "security": "tls",
        "tlsSettings": {},
        "wsSettings": {},
        "sockopt": {
          "dialerProxy": "fragment",
          "mark": 255
        }
      }
    },
    {
      "tag": "fragment",
      "protocol": "freedom",
      "settings": {
        "fragment": {
          "packets": "tlshello",
          "length": "100-200",
          "interval": "10-20"
        }
      },
      "streamSettings": {
        "sockopt": {
          "TcpNoDelay": true,
          "mark": 255
        }
      }
    }
  ]
}

@2dust
Copy link
Owner

2dust commented Feb 12, 2024

"sockopt": {
          "dialerProxy": "fragment",
          "mark": 255
        }

Please note that fragment needs to use chain proxy
My suggestion is not to do UI interface, please use custom configuration
@vfarid thank you for your work,And not all countries require it, especially in China, so very complicated changes will not be accepted.

@vfarid
Copy link
Contributor Author

vfarid commented Feb 12, 2024

@2dust thanks for your review and i understand its may not needed for all countries at the time but for iran it is a need.
If you accept, i can seperate changes into 3 different pull requesets and we can go step by step:

Make it possible to share fragment together with normal configs (in addition to custom configs). This will help users share configs easier because custom configs are hard to copy/pase/import for untrained users.

Add global settings for fragment (near mux settings)

Keep UI for fragments in config edit page and show them only for configs with fragment and for users who globally activated fragment. This way the change will not affect on UI of users in china or other countries who dont need fragment at all.

Furtheremore, in iran we need scanner for cloudflare's clean IP and since every operator have different mechanism, this should be done on user's device. Do you think it is acceptable to add an internal ip scanner in this app? If so i can work on it as well.

Thank you in advance.

@2dust
Copy link
Owner

2dust commented Feb 12, 2024

Please use custom configuration to test whether the fragment is valid first.

if valid then

  1. Add global settings for fragment (near mux settings)
  2. If fragment is enabled, generates configuration
  3. No need to modify other interfaces and sharing configurations

Keep UI for fragments in config edit page and show them only for configs with fragment and for users who globally activated fragment. This way the change will not affect on UI of users in china or other countries who dont need fragment at all.

This is unnecessary

@2dust
Copy link
Owner

2dust commented Feb 12, 2024

XTLS/Xray-core#2392

@2dust 2dust closed this Feb 12, 2024
@vfarid
Copy link
Contributor Author

vfarid commented Feb 12, 2024

Ok, plase take a look at this comment as well to make sure it works:
XTLS/Xray-core#2392 (comment)

@iamtheted
Copy link

Please use custom configuration to test whether the fragment is valid first.

if valid then

  1. Add global settings for fragment (near mux settings)
  2. If fragment is enabled, generates configuration
  3. No need to modify other interfaces and sharing configurations

Keep UI for fragments in config edit page and show them only for configs with fragment and for users who globally activated fragment. This way the change will not affect on UI of users in china or other countries who dont need fragment at all.

This is unnecessary

Hello @2dust
Hope you're all well.

With all due respect, I believe adding custom config is not user-friendly.
Ordinary people can't add custom configs therefore those settings within the config can be a lot better.
I am aware this feature doesn't mean anything for Chinese users but Iranians could benefit from it.
Please think this through and see if you can reconsider.
Thank a lot for everything.

@iamtheted
Copy link

Please use custom configuration to test whether the fragment is valid first.

if valid then

  1. Add global settings for fragment (near mux settings)
  2. If fragment is enabled, generates configuration
  3. No need to modify other interfaces and sharing configurations

Keep UI for fragments in config edit page and show them only for configs with fragment and for users who globally activated fragment. This way the change will not affect on UI of users in china or other countries who dont need fragment at all.

This is unnecessary

@2dust Hello Again,
At least change the fragment settings in a certain way that Reality configs are not affected, is that doable?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants