[GH-ISSUE #103] Plugin to enable more then one address/port on connection and automatically switch them #87

Closed
opened 2026-02-26 11:56:41 +03:00 by kerem · 11 comments
Owner

Originally created by @allanpk716 on GitHub (Mar 30, 2021).
Original GitHub issue: https://github.com/1Remote/1Remote/issues/103

Originally assigned to: @VShawn on GitHub.

Is your feature request related to a problem? Please describe.

It's not a problem. it's a new feature.
In some cases, I have a server, it can be connected in 2 ways ( 1. LAN. 2. FRP local host ), so i need create 2 connection items in PRemote and I need remember where am I then use which connection item to connect the server.

在某些应用场景下,比如我有一台服务器,然后可以有两种连接到它的方式(1,局域网直连。2,FRP 映射端口后本地连接)。现在就需要创建两个连接的选项卡。然后在公司在家或者外出,需要使用的时候,得想一下到底得用那个连接选项卡才对。

Describe the solution you'd like

So I add a feature, that you can only create one connection item , use anywhere. see Premote-Plugin-SmartProtocol

现在我简单实现了一个“智能”协议,这样只需要新建一个连接选项卡即可。详情请见 Premote-Plugin-SmartProtocol

Describe alternatives you've considered
see Premote-Plugin-SmartProtocol

Additional context
no

Originally created by @allanpk716 on GitHub (Mar 30, 2021). Original GitHub issue: https://github.com/1Remote/1Remote/issues/103 Originally assigned to: @VShawn on GitHub. **Is your feature request related to a problem? Please describe.** It's not a problem. it's a new feature. In some cases, I have a server, it can be connected in 2 ways ( 1. LAN. 2. FRP local host ), so i need create 2 connection items in PRemote and I need remember where am I then use which connection item to connect the server. 在某些应用场景下,比如我有一台服务器,然后可以有两种连接到它的方式(1,局域网直连。2,FRP 映射端口后本地连接)。现在就需要创建两个连接的选项卡。然后在公司在家或者外出,需要使用的时候,得想一下到底得用那个连接选项卡才对。 **Describe the solution you'd like** So I add a feature, that you can only create one connection item , use anywhere. see [Premote-Plugin-SmartProtocol](https://github.com/allanpk716/Premote-Plugin-SmartProtocol) 现在我简单实现了一个“智能”协议,这样只需要新建一个连接选项卡即可。详情请见 [Premote-Plugin-SmartProtocol](https://github.com/allanpk716/Premote-Plugin-SmartProtocol) **Describe alternatives you've considered** see [Premote-Plugin-SmartProtocol](https://github.com/allanpk716/Premote-Plugin-SmartProtocol) **Additional context** no
Author
Owner

@majkinetor commented on GitHub (Mar 30, 2021):

Couldn't this be already done with pre-connect command ?

<!-- gh-comment-id:810119505 --> @majkinetor commented on GitHub (Mar 30, 2021): Couldn't this be already done with pre-connect command ?
Author
Owner

@allanpk716 commented on GitHub (Mar 30, 2021):

Couldn't this be already done with pre-connect command ?

No, PRemote need communicate with it. When PRemote get the value back and need change the IP and port to the best way then to connect. Of course, this's change only IP/PORT config in memory , does not affect the actual storage.

这个插件需要与 PRemote 交互,然后获取到最佳的返回值后,需要动态修改连接的 IP 和 Port。当然这个是内存级的,不会影响实际的存储,当次有效。

<!-- gh-comment-id:810129473 --> @allanpk716 commented on GitHub (Mar 30, 2021): > Couldn't this be already done with pre-connect command ? No, PRemote need communicate with it. When PRemote get the value back and need change the IP and port to the best way then to connect. Of course, this's change only IP/PORT config in memory , does not affect the actual storage. 这个插件需要与 PRemote 交互,然后获取到最佳的返回值后,需要动态修改连接的 IP 和 Port。当然这个是内存级的,不会影响实际的存储,当次有效。
Author
Owner

@majkinetor commented on GitHub (Mar 30, 2021):

You could dynamically add entry in hosts file in pre connect script, although you would need to use the same port. Port could be fixed tho by option of pre connect script to return back some data, and then it could also return any parameter connection. For example if powershell script is called, it could return something like

@{ Address = '1.2.3.4'; Port = '8000 ' }

or if cmd is called, it could return that in local env vars.

Now, not sure if that is easier or not, but is definitely more general solution as you could literary do anything you want, including setting up VPN/FRP or whatever.

So, your solution (since you didn't give screenshots) is to add multiple IP/PORT settings to connection ? How would PRM know which one to use ? Any one that works ?

<!-- gh-comment-id:810133892 --> @majkinetor commented on GitHub (Mar 30, 2021): You could dynamically add entry in hosts file in pre connect script, although you would need to use the same port. Port could be fixed tho by option of pre connect script to return back some data, and then it could also return any parameter connection. For example if powershell script is called, it could return something like `@{ Address = '1.2.3.4'; Port = '8000 ' }` or if cmd is called, it could return that in local env vars. Now, not sure if that is easier or not, but is definitely more general solution as you could literary do anything you want, including setting up VPN/FRP or whatever. So, your solution (since you didn't give screenshots) is to add multiple IP/PORT settings to connection ? How would PRM know which one to use ? Any one that works ?
Author
Owner

@allanpk716 commented on GitHub (Mar 30, 2021):

You could dynamically add entry in hosts file in pre connect script, although you would need to use the same port. Port could be fixed tho by option of pre connect script to return back some data, and then it could also return any parameter connection. For example if powershell script is called, it could return something like

@{ Address = '1.2.3.4'; Port = '8000 ' }

or if cmd is called, it could return that in local env vars.

Now, not sure if that is easier or not, but is definitely more general solution as you could literary do anything you want, including setting up VPN/FRP or whatever.

So, your solution (since you didn't give screenshots) is to add multiple IP/PORT settings to connection ? How would PRM know which one to use ? Any one that works ?

see this page, will tell you how it worked. Premote-Plugin-SmartProtocol 😄

<!-- gh-comment-id:810137291 --> @allanpk716 commented on GitHub (Mar 30, 2021): > You could dynamically add entry in hosts file in pre connect script, although you would need to use the same port. Port could be fixed tho by option of pre connect script to return back some data, and then it could also return any parameter connection. For example if powershell script is called, it could return something like > > `@{ Address = '1.2.3.4'; Port = '8000 ' }` > > or if cmd is called, it could return that in local env vars. > > Now, not sure if that is easier or not, but is definitely more general solution as you could literary do anything you want, including setting up VPN/FRP or whatever. > > So, your solution (since you didn't give screenshots) is to add multiple IP/PORT settings to connection ? How would PRM know which one to use ? Any one that works ? see this page, will tell you how it worked. [Premote-Plugin-SmartProtocol](https://github.com/allanpk716/Premote-Plugin-SmartProtocol) :smile:
Author
Owner

@majkinetor commented on GitHub (Mar 30, 2021):

OK, thx:

SPConfig.yaml

So addresses are in another config file. Complicated IMO :)

As this is basically pre-processing of existing connection, I think we should go with script returning this. For example in Powershell that would be something like:

function Smart-Connection ($Options) {
    foreach ($option in $Options) {
        $ip, $port = $option -split ':'
        if (Test-Connection -TargetName $ip -TcpPort $port -TimeoutSeconds 5) {
            return $ip, $port
        }
    }
    throw 'No connection available'
}

image

PRM could even allow specifying entire script in configuration (so that no external files are needed).

This solution is way more general of course and solves need for infinity number of plugins.

<!-- gh-comment-id:810146020 --> @majkinetor commented on GitHub (Mar 30, 2021): OK, thx: > SPConfig.yaml So addresses are in another config file. Complicated IMO :) As this is basically pre-processing of existing connection, I think we should go with script returning this. For example in Powershell that would be something like: ```powershell function Smart-Connection ($Options) { foreach ($option in $Options) { $ip, $port = $option -split ':' if (Test-Connection -TargetName $ip -TcpPort $port -TimeoutSeconds 5) { return $ip, $port } } throw 'No connection available' } ``` ![image](https://user-images.githubusercontent.com/85767/112981769-eda50b00-915b-11eb-8198-29a1351e2bee.png) PRM could even allow specifying entire script in configuration (so that no external files are needed). This solution is way more general of course and solves need for infinity number of plugins.
Author
Owner

@allanpk716 commented on GitHub (Mar 30, 2021):

  1. External script is too slow to do this things.
  2. IMO, *.ps1 script is more hard to read and write, and not suitable for deal with this job, it's need multi threading.
  3. It doesn't solve the problem of communicate with the main program and still requires additional coding.

Now it's just an extra configurator or interaction to do the setup.

And this pull request, does not affect the use of ordinary people, can wait for the subsequent interaction can be improved.

<!-- gh-comment-id:810157179 --> @allanpk716 commented on GitHub (Mar 30, 2021): 1. External script is too slow to do this things. 2. IMO, *.ps1 script is more hard to read and write, and not suitable for deal with this job, it's need multi threading. 3. It doesn't solve the problem of communicate with the main program and still requires additional coding. Now it's just an extra configurator or interaction to do the setup. And this pull request, does not affect the use of ordinary people, can wait for the subsequent interaction can be improved.
Author
Owner

@majkinetor commented on GitHub (Mar 30, 2021):

External script is too slow to do this things.

Facts please, not wishful thinking: any script - PoweShell (with adequate params) or cmd can execute within 1s especially cmd which is probably almost instant but has very bad programming capabilities.

Also, do you really need ultimate speed here ? Its not that different If you connect in 100ms or 3 seconds in non regular weird use case, what is important is easiness of setup and options, no weird surprises in 99% of cases, and approachable mental model of application.

IMO, *.ps1 script is more hard to read and write,

Really ? I provided 4 lines instead of your 100+ lines or so ? It could be one liner really.

and not suitable for deal with this job, it's need multi threading.

The above command support multithreading, as posh in general, see example 1 or example 2. I just didn't use it to show the concept.

It doesn't solve the problem of communicate with the main program and still requires additional coding.

It solves the problem if script communicates back. It also solves 1M other problems.

To me this kind of feature is what categorizes as scratching ones itch. It bloats the main tool, requires maintenance and extra documentation and so on. I am not against having it, just not within main codebase , perhaps there should be external plugins repository. Then maintenance of this plugin isn't on main dev but community. Scripting extensions could be good for easy to use no-development-tools-needed cases as those come out of the box with operating system and don't require anything but notepad.

Of course, that is my personal opinion, please don't take this as something against your work which is nice idea. @VShawn might have totally other one.

<!-- gh-comment-id:810252092 --> @majkinetor commented on GitHub (Mar 30, 2021): > External script is too slow to do this things. Facts please, not wishful thinking: any script - PoweShell (with adequate params) or cmd can execute within 1s especially cmd which is probably almost instant but has very bad programming capabilities. Also, do you really need ultimate speed here ? Its not that different If you connect in 100ms or 3 seconds in non regular weird use case, what is important is easiness of setup and options, no weird surprises in 99% of cases, and approachable mental model of application. > IMO, *.ps1 script is more hard to read and write, Really ? I provided 4 lines instead of your 100+ lines or so ? It could be one liner really. > and not suitable for deal with this job, it's need multi threading. The above command support multithreading, as posh in general, see [example 1](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/test-connection?view=powershell-7.1#example-2--send-echo-requests-to-several-computers) or [example 2](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/test-connection?view=powershell-7.1#example-4--run-a-test-as-a-background-job). I just didn't use it to show the concept. > It doesn't solve the problem of communicate with the main program and still requires additional coding. It solves the problem if script communicates back. It also solves 1M other problems. To me this kind of feature is what categorizes as scratching ones itch. It bloats the main tool, requires maintenance and extra documentation and so on. I am not against having it, just not within main codebase , perhaps there should be external plugins repository. Then maintenance of this plugin isn't on main dev but community. Scripting extensions could be good for easy to use no-development-tools-needed cases as those come out of the box with operating system and don't require anything but notepad. Of course, that is my personal opinion, please don't take this as something against your work which is nice idea. @VShawn might have totally other one.
Author
Owner

@allanpk716 commented on GitHub (Mar 30, 2021):

I want know 1M other problem is?

<!-- gh-comment-id:810288925 --> @allanpk716 commented on GitHub (Mar 30, 2021): I want know 1M other problem is?
Author
Owner

@allanpk716 commented on GitHub (Mar 30, 2021):

You talk a lot, but you don't solve the problem of external execution and then changing the local IP and port.Don't just give that solution when you don't know what the requirements are.

<!-- gh-comment-id:810293874 --> @allanpk716 commented on GitHub (Mar 30, 2021): You talk a lot, but you don't solve the problem of external execution and then changing the local IP and port.Don't just give that solution when you don't know what the requirements are.
Author
Owner

@VShawn commented on GitHub (Mar 30, 2021):

This implementation seems very controversial, and the merger is put on hold.

For me, this feature is dispensable. I created two profiles for the local network and public network of a server, and I didn't feel it troublesome in switching them.

I dont like this implement with external tool, it‘s not friendly to config, and the address in external is not been encrypted, and it can not publish to Microsoft Store, but I don’t have a better idea, I once designed to allow a profile to contain multiple IP addresses and allow people to choose from the launcher menu, but this design would break the basic data structure in PRM, so I have not made my mind to change PRM like this.

<!-- gh-comment-id:810294731 --> @VShawn commented on GitHub (Mar 30, 2021): This implementation seems very controversial, and the merger is put on hold. For me, this feature is dispensable. I created two profiles for the local network and public network of a server, and I didn't feel it troublesome in switching them. I dont like this implement with external tool, it‘s not friendly to config, and the address in external is not been encrypted, and it can not publish to Microsoft Store, but I don’t have a better idea, I once designed to allow a profile to contain multiple IP addresses and allow people to choose from the launcher menu, but this design would break the basic data structure in PRM, so I have not made my mind to change PRM like this.
Author
Owner

@allanpk716 commented on GitHub (Mar 30, 2021):

Why don't you first think about what the solution is supposed to solve and then come up with a workable solution instead of just saying something that doesn't really matter

<!-- gh-comment-id:810295192 --> @allanpk716 commented on GitHub (Mar 30, 2021): Why don't you first think about what the solution is supposed to solve and then come up with a workable solution instead of just saying something that doesn't really matter
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/1Remote#87
No description provided.