Author

Topic: [PATCH REQUEST] Variable ports (205BTC reward) (Read 10221 times)

administrator
Activity: 4228
Merit: 8647
December 25, 2010, 07:17:06 PM
#28
Interesting, is this by design or a bug?

It's by design. Here is Bitcoin choosing which peers to connect to:
Code:
// Randomize the order in a deterministic way, putting the standard port first
int64 nRandomizer = (uint64)(nStart * 4951 + addr.nLastTry * 9567851 + addr.ip * 7789) % (2 * 60 * 60);
if (addr.port != GetDefaultPort())
    nRandomizer += 2 * 60 * 60;
dsg
newbie
Activity: 37
Merit: 0
On a related note: from discussion on IRC I understood that the peer exchange protocol somehow doesn't have support for alternative ports. Does this patch work as advertised at all?

The protocol supports alternative ports just fine, though you won't receive incoming connections because Bitcoin prefers not to connect to peers that are using non-standard ports.

Interesting, is this by design or a bug?

I think it will be imperative for bitcoin to randomise port and use encryption, in order to avoid being blocked by firewalls or DPI boxes. Hopefully this will be implemented before it's needed.
administrator
Activity: 4228
Merit: 8647
On a related note: from discussion on IRC I understood that the peer exchange protocol somehow doesn't have support for alternative ports. Does this patch work as advertised at all?

The protocol supports alternative ports just fine, though you won't receive incoming connections because Bitcoin prefers not to connect to peers that are using non-standard ports.
hero member
Activity: 812
Merit: 1011
No Maps for These Territories
This patch doesn't work anymore.  Is this still necessary or has it made it into official svn?
Nope, it's not in official SVN yet.

On a related note: from discussion on IRC I understood that the peer exchange protocol somehow doesn't have support for alternative ports. Does this patch work as advertised at all?
hero member
Activity: 574
Merit: 504
This patch doesn't work anymore.  Is this still necessary or has it made it into official svn?
hero member
Activity: 574
Merit: 504
original post edited to include link to patch.
legendary
Activity: 1596
Merit: 1022
Patch updated for latest SVN.
hero member
Activity: 574
Merit: 504
no reason to change that, as other clients only try to connect to 8333, afaict. IRC only advertises IP, right?

No, both IP and port are encoded in the #bitcoin IRC usernames (see the EncodeAddress/DecodeAddress routines in irc.cpp).

(so mizerydearia:  no need to do what you done did...)

Mm...  On a slightly unrelated issue.  Since it is possible to detect majority of all nodes in the p2p network by visiting the bootstrapping irc channel, it seems fairly easy to determine where exactly all the nodes are in case any attempt to disconnect Internet or seize hardwares ever occurs.  Perhaps another thread should be used to discuss this.
legendary
Activity: 1540
Merit: 1000
no reason to change that, as other clients only try to connect to 8333, afaict. IRC only advertises IP, right?

No, both IP and port are encoded in the #bitcoin IRC usernames (see the EncodeAddress/DecodeAddress routines in irc.cpp).

(so mizerydearia:  no need to do what you done did...)

So I could use -inboundport= and use that instead of DEFAULT_PORT, or if 0 disable inbound completely like I do now. Hmmm, I feel a patch to your patch coming.
legendary
Activity: 1652
Merit: 1186
Chief Scientist
no reason to change that, as other clients only try to connect to 8333, afaict. IRC only advertises IP, right?

No, both IP and port are encoded in the #bitcoin IRC usernames (see the EncodeAddress/DecodeAddress routines in irc.cpp).

(so mizerydearia:  no need to do what you done did...)
hero member
Activity: 574
Merit: 504
no reason to change that, as other clients only try to connect to 8333, afaict. IRC only advertises IP, right?

For IRC I set my user name to 8332 and my real name to 8333 as per server connection configuration and then connected.
Code:
/whois necrodearia
[necrodearia] ([email protected]): 8333
* [necrodearia] #bitcoin-dev #bitcoin
* [necrodearia] peacock.heliacal.net :Chicago, IL USA
* [necrodearia] idle 00:00:09, signon: Tue Sep 21 07:46:38
* [necrodearia] End of WHOIS list.

Using this method, it is possible to embed port numbers that a client is using into their IRC connection so that ports are not restricted to 8332 and 8333.  I suggest implementing this or a related implementation into a future version of Bitcoin.

Satoshi o/
legendary
Activity: 1540
Merit: 1000
I know my usecase (multiple bitcoin clients on the same server) is not the same thing that is being solved by this patch, it does fix most of it. The only thing remaining is to prevent binding to 8333 (no reason to change that, as other clients only try to connect to 8333, afaict. IRC only advertises IP, right?).

I've patched my client with this simple change:
Code:
--- a/net.cpp
+++ b/net.cpp
@@ -1236,6 +1236,9 @@ bool BindListenPort(string& strError)
     memset(&sockaddr, 0, sizeof(sockaddr));
     sockaddr.sin_family = AF_INET;
     sockaddr.sin_addr.s_addr = INADDR_ANY; // bind to all IPs on this computer
+    if (mapArgs.count("-disableinbound")) {
+      return true;
+    }
     sockaddr.sin_port = DEFAULT_PORT;
     if (::bind(hListenSocket, (struct sockaddr*)&sockaddr, sizeof(sockaddr)) == SOCKET_ERROR)
     {

so passing the -disableinbound switch makes it not try to bind the 8333 port.
full member
Activity: 307
Merit: 101
Patch updated for latest SVN.  Given recent upstream changes to support binding to any address (0.0.0.0 or '*'), this patch is reduced to adding an option to bind or connect to a non-standard, not 8332 port:

URL: http://yyz.us/bitcoin/patch.bitcoin-bindaddr


I've added the new bindaddr patch to my client.
legendary
Activity: 1596
Merit: 1022
Patch updated for latest SVN.  Given recent upstream changes to support binding to any address (0.0.0.0 or '*'), this patch is reduced to adding an option to bind or connect to a non-standard, not 8332 port:

URL: http://yyz.us/bitcoin/patch.bitcoin-bindaddr
legendary
Activity: 1596
Merit: 1022
I've now removed jgarzik's patch from my client in favor of using Satoshi's -rpcallowip setting (since it's in the vanilla svn).

But that doesn't allow separate ports to run multiple clients on the same machine, does it?

I'll update my patch on top of -rpcallowip soonish...  The JSON-RPC port is still hardcoded as 8332 in vanilla svn Sad
full member
Activity: 307
Merit: 101
I've now removed jgarzik's patch from my client in favor of using Satoshi's -rpcallowip setting (since it's in the vanilla svn).

But that doesn't allow separate ports to run multiple clients on the same machine, does it?

That is correct, but my main concern was being able to connect to the JSON-RPC interface from somewhere other than localhost. Specifically so that I could manage my nodes with phpMyBitcoin.
legendary
Activity: 1540
Merit: 1000
I've now removed jgarzik's patch from my client in favor of using Satoshi's -rpcallowip setting (since it's in the vanilla svn).

But that doesn't allow separate ports to run multiple clients on the same machine, does it?
full member
Activity: 307
Merit: 101
I've now removed jgarzik's patch from my client in favor of using Satoshi's -rpcallowip setting (since it's in the vanilla svn).
hero member
Activity: 574
Merit: 504
Ah, cool.  Thanks for the confirmation.
full member
Activity: 307
Merit: 101
September 15, 2010, 09:39:52 PM
#9
This doesn't seem to be compatible with Slight change so that JSON-RPC binds to all/any IPs instead of just the loopback..  Can these patches be combined or is one better than the other?

Those two patches attempt similar things, and so should be considered mutually incompatible.


Yup, I've removed my patch, as jgarzik's is better (mine was just a simple hack).
legendary
Activity: 1596
Merit: 1022
September 15, 2010, 03:55:43 PM
#8
This doesn't seem to be compatible with Slight change so that JSON-RPC binds to all/any IPs instead of just the loopback..  Can these patches be combined or is one better than the other?

Those two patches attempt similar things, and so should be considered mutually incompatible.
hero member
Activity: 574
Merit: 504
September 15, 2010, 03:38:02 PM
#7
This doesn't seem to be compatible with Slight change so that JSON-RPC binds to all/any IPs instead of just the loopback..  Can these patches be combined or is one better than the other?
full member
Activity: 307
Merit: 101
September 09, 2010, 11:41:07 AM
#6
Thank you jgarzik. The patch is working great, and I've sent the 200 BTC to the address in your signature.
legendary
Activity: 1596
Merit: 1022
September 09, 2010, 03:16:52 AM
#5

Does this patch work for you guys?

     http://yyz.us/bitcoin/patch.bitcoin-bindaddr

The patch adds four command line parameters,

     -bindaddr=W.X.Y.Z      Bind to address W.X.Y.Z, instead of 127.0.0.1.  Supports bind-any modes via "*" and "0.0.0.0" addresses.
     -bindport=X         Bind to port X, instead of 8332
     -rpcaddr=W.X.Y.Z       Connect to address W.X.Y.Z, instead of 127.0.0.1
     -rpcport=X           Connect to port X, instead of 8332

Because of the way bitcoin works, all command line parameters may be specifed in the config file.  Therefore, the above would be added to the config file like this,

Code:
bindaddr=W.X.Y.Z
bindport=X
rpcaddr=W.X.Y.Z
rpcport=X
full member
Activity: 307
Merit: 101
September 09, 2010, 01:39:04 AM
#4
If someone wrote a patch that lets me set the IP/port for JSON-RPC in bitcoin.conf, I'll send them 200 BTC.  Grin
hero member
Activity: 574
Merit: 504
September 05, 2010, 02:13:17 AM
#3
(I am poor)
Quote
Bitcoin donations received: 344.29

You probably didn't need to claim poverty.

I've donated to others as well, especially nanotube who has helped me a lot with bitbot!  The amount in the image is not indicative of how much I have, but rather total amount of donations overall.  Also, I would like to preserve some balance for future usage/expenditures/donations.  However, beyond scope of my Bitcoin balance, I am still unemployed and have no money remaining for any purpose (including foods) and am still lazy other than dedicating most of my time/effort towards Bitcoin-related projects.
sr. member
Activity: 294
Merit: 251
Firstbits: 1duzy
September 05, 2010, 01:59:42 AM
#2
(I am poor)
Quote
Bitcoin donations received: 344.29

You probably didn't need to claim poverty.
hero member
Activity: 574
Merit: 504
September 05, 2010, 12:46:52 AM
#1
I would like to request for a patch to be developed that allows a bitcoin client to have configurable ports (currently 8332 and 8333) using configuration file to determine which ports to use.  So as to incentivize development for this patch I would like to offer 5btc (I am poor) and if anyone else would like to additionally contribute so as to offer more incentive, feel free to reply.

    5btc (miz)
+ 200btc (aceat64)
--------
  205btc


jgarzik's patch
Jump to: