Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: mizerydearia on September 05, 2010, 05:46:52 AM



Title: [PATCH REQUEST] Variable ports (205BTC reward)
Post by: mizerydearia on September 05, 2010, 05:46:52 AM
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 (http://bitcointalk.org/index.php?topic=984.msg12288#msg12288))
--------
  205btc


jgarzik's patch (http://yyz.us/bitcoin/patch.bitcoin-bindaddr)


Title: Re: [PATCH REQUEST] Variable ports (5BTC reward)
Post by: Insti on September 05, 2010, 06:59:42 AM
(I am poor)
Quote
Bitcoin donations received: 344.29

You probably didn't need to claim poverty.


Title: Re: [PATCH REQUEST] Variable ports (5BTC reward)
Post by: mizerydearia on September 05, 2010, 07:13:17 AM
(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 (http://bitcointalk.org/index.php?topic=372.msg3099#msg3099) 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.


Title: Re: [PATCH REQUEST] Variable ports (5BTC reward)
Post by: aceat64 on September 09, 2010, 06:39:04 AM
If someone wrote a patch that lets me set the IP/port for JSON-RPC in bitcoin.conf, I'll send them 200 BTC.  ;D


Title: Re: [PATCH REQUEST] Variable ports (205BTC reward)
Post by: jgarzik on September 09, 2010, 08:16:52 AM

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


Title: Re: [PATCH REQUEST] Variable ports (205BTC reward)
Post by: aceat64 on September 09, 2010, 04:41:07 PM
Thank you jgarzik. The patch is working great, and I've sent the 200 BTC to the address in your signature.


Title: Re: [PATCH REQUEST] Variable ports (205BTC reward)
Post by: mizerydearia on September 15, 2010, 08:38:02 PM
This doesn't seem to be compatible with Slight change so that JSON-RPC binds to all/any IPs instead of just the loopback. (http://bitcointalk.org/index.php?topic=611.msg11859#msg11859).  Can these patches be combined or is one better than the other?


Title: Re: [PATCH REQUEST] Variable ports (205BTC reward)
Post by: jgarzik on September 15, 2010, 08:55:43 PM
This doesn't seem to be compatible with Slight change so that JSON-RPC binds to all/any IPs instead of just the loopback. (http://bitcointalk.org/index.php?topic=611.msg11859#msg11859).  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.


Title: Re: [PATCH REQUEST] Variable ports (205BTC reward)
Post by: aceat64 on September 16, 2010, 02:39:52 AM
This doesn't seem to be compatible with Slight change so that JSON-RPC binds to all/any IPs instead of just the loopback. (http://bitcointalk.org/index.php?topic=611.msg11859#msg11859).  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).


Title: Re: [PATCH REQUEST] Variable ports (205BTC reward)
Post by: mizerydearia on September 16, 2010, 07:54:52 AM
Ah, cool.  Thanks for the confirmation.


Title: Re: [PATCH REQUEST] Variable ports (205BTC reward)
Post by: aceat64 on September 16, 2010, 05:06:50 PM
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).


Title: Re: [PATCH REQUEST] Variable ports (205BTC reward)
Post by: nelisky on September 16, 2010, 05:15:32 PM
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?


Title: Re: [PATCH REQUEST] Variable ports (205BTC reward)
Post by: aceat64 on September 16, 2010, 05:28:40 PM
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.


Title: Re: [PATCH REQUEST] Variable ports (205BTC reward)
Post by: jgarzik on September 16, 2010, 05:57:26 PM
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 :(


Title: Re: [PATCH REQUEST] Variable ports (205BTC reward)
Post by: jgarzik on September 18, 2010, 07:43:56 PM
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 (http://yyz.us/bitcoin/patch.bitcoin-bindaddr)


Title: Re: [PATCH REQUEST] Variable ports (205BTC reward)
Post by: aceat64 on September 19, 2010, 05:36:13 AM
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 (http://yyz.us/bitcoin/patch.bitcoin-bindaddr)


I've added the new bindaddr patch to my client.


Title: Re: [PATCH REQUEST] Variable ports (205BTC reward)
Post by: nelisky on September 21, 2010, 01:59:54 AM
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.


Title: Re: [PATCH REQUEST] Variable ports (205BTC reward)
Post by: mizerydearia on September 21, 2010, 12:49:37 PM
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] (8332@address.net): 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/


Title: Re: [PATCH REQUEST] Variable ports (205BTC reward)
Post by: Gavin Andresen on September 21, 2010, 01:31:38 PM
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...)


Title: Re: [PATCH REQUEST] Variable ports (205BTC reward)
Post by: nelisky on September 21, 2010, 01:54:08 PM
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=<port> 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.


Title: Re: [PATCH REQUEST] Variable ports (205BTC reward)
Post by: mizerydearia on September 22, 2010, 12:11:18 AM
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 (http://bitcointalk.org/index.php?topic=1068.0) should be used to discuss this.


Title: Re: [PATCH REQUEST] Variable ports (205BTC reward)
Post by: jgarzik on September 29, 2010, 05:31:55 PM
Patch updated for latest SVN.


Title: Re: [PATCH REQUEST] Variable ports (205BTC reward)
Post by: mizerydearia on September 29, 2010, 05:35:18 PM
original post edited to include link to patch.


Title: Re: [PATCH REQUEST] Variable ports (205BTC reward)
Post by: mizerydearia on December 24, 2010, 12:11:45 PM
This patch doesn't work anymore.  Is this still necessary or has it made it into official svn?


Title: Re: [PATCH REQUEST] Variable ports (205BTC reward)
Post by: wumpus on December 24, 2010, 01:21:54 PM
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?


Title: Re: [PATCH REQUEST] Variable ports (205BTC reward)
Post by: theymos on December 24, 2010, 08:49:20 PM
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.


Title: Re: [PATCH REQUEST] Variable ports (205BTC reward)
Post by: dsg on December 26, 2010, 12:09:36 AM
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.


Title: Re: [PATCH REQUEST] Variable ports (205BTC reward)
Post by: theymos on December 26, 2010, 12:17:06 AM
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;