Gozargah / Marzban-node

Proxy Node for Marzban
GNU Affero General Public License v3.0
166 stars 73 forks source link

Add feature: ability to only pick inbounds meant for specify node #16

Closed X-Oracle closed 1 year ago

X-Oracle commented 1 year ago

This is an optional feature which allows admins to specify which inbounds should be used in node Xray.

Benefits :

This is compatible with current Marzban and needs nothing to be done in Master server python codes.

In order to use this future Admin needs to add one key called "node_ip" in inbounds wanted to only be used in node Xray. like:

"inbounds" : [
      {
          "node_ip": "1.2.3.4",
          // other settings
      }
      // other inbounds
    ]

For bellow conditions this future won't be used, and the behavior would be just like before (adding all inbounds to node Xray):

SaintShit commented 1 year ago

I think this can be a great temp solution, but what if we want an inbound to be working on multiple nodes?

govfvck commented 1 year ago

Yeah. I think that's a great idea, but this solution could be better. I think ip is not a great choice for node seperation because it might change any time.

X-Oracle commented 1 year ago

I think this can be a great temp solution, but what if we want an inbound to be working on multiple nodes?

Well in that case we can make it a list of ips instead of a single ip string.

I do proper changes .

I think ip is not a great choice for node seperation because it might change any time.

The proper way would be that marzban send a name or id which was required when registering a new node , to the node server when connecting to it .

Only In that case we can use name or id to do the identification.

But for now it is the only way I can think of .

X-Oracle commented 1 year ago

also, I changed "node_ip" to "node_ips".

now it should be like this ...

"inbounds" : [
      {
          "node_ips": [
                            "1.2.3.4",
                            "5.6.7.8"
                           ]
          // other settings
      }
      // other inbounds
    ]
govfvck commented 1 year ago

The proper way would be that marzban send a name or id which was required when registering a new node , to the node server when connecting to it .

Only In that case we can use name or id to do the identification.

But for now it is the only way I can think of .

You're right, but I think we should do it now rather than later. we might get in to some troubles migrating from this to something else in the future. @SaintShit what do you think?

X-Oracle commented 1 year ago

You're right, but I think we should do it now rather than later. we might get in to some troubles migrating from this to something else in the future.

With these changes admin only needs to change xray-config of the main server.

And these configs won't do harm unless they conflict with xray objects which is not the case here.

And if Marzban gets an update to support similar and better functionality then this PR changes can easily be ignored or removed. Like I said before...

For bellow conditions this future won't be used, and the behavior would be just like before (adding all inbounds to node Xray):

  • If "node_ip" was not used in any inbounds.
govfvck commented 1 year ago

I meant for the people using this feature, if we remove this in an update later people might have some difficulty to migrate to the new version.

it's just a thought that we should consider. sorry I can't submit a review now because I didn't check/test the code yet, but I'll try my best to do it as soon as possible.

X-Oracle commented 1 year ago

I think ip is not a great choice for node seperation because it might change any time.

@govfvck Now 'node_ips' can get both ips and domains . https://github.com/Gozargah/Marzban-node/pull/16/commits/4e099ee551f2a07d55dda88b9e2a03d1016f61e3 so, when admins change domain ip it will change too. it will use node dns to resolve the domains then do the comparison.