Coder Social home page Coder Social logo

Comments (10)

robclark56 avatar robclark56 commented on May 27, 2024 1

I think it was because I updated my raspibolt script to bash instead of /bin/sh
#!/bin/bash

In bash you check equality of STRINGS with ==.
And I converted $public_check to a string as follows: "$public_check" (added quotes)

But by all means do what works. I am not an expert on shell scripting at all.

:-)

from raspibolt.

Stadicus avatar Stadicus commented on May 27, 2024

Good catch, might be the cause for some of the issues raised here. Do you know of a different method to check the public availability of the Bitcoin node?

from raspibolt.

robclark56 avatar robclark56 commented on May 27, 2024

Sorry no.

Tried without success to fine an alternative service.

from raspibolt.

robclark56 avatar robclark56 commented on May 27, 2024

Found a solution. The Raspibolt itself can check if a port is open. While I do like the idea for a completely external check e.g. from https://bitnodes.earn.com, as we see - that can cause problem.

in the raspibolt script, change

public_check=$(curl -s https://bitnodes.earn.com/api/v1/nodes/me-${public_port}/ | jq .success)
if [ $public_check = "true" ]; then

to

public_check=$(timeout 2s nc -z ${public_ip} ${public_port}; echo $?)
if [ "$public_check" == "0" ]; then

from raspibolt.

Stadicus avatar Stadicus commented on May 27, 2024

Hi @robclark56, I tried to figure out how this should work. As long as I use my own ip address, netcat always return no value. Which means 'you are public', I guess?

2018-07-12 02_36_47-window

Am I missing something?

from raspibolt.

robclark56 avatar robclark56 commented on May 27, 2024

nc -z IP PORT returns:

  • 0 if success (ie PORT on IP is open)
  • Non-Zero if failure (ie Port is not open)

Here are my examples (8333 is open, 12345 is not)

admin ~  ฿  nc -z  106.68.62.191 8333
admin ~  ฿  echo $?
0
admin ~  ฿  nc -z  106.68.62.191 12345
[..... long wait ....]
admin ~  ฿  echo $?
1

And here it is verbose

admin ~  ฿  nc -vz  106.68.62.191 8333
Connection to 106.68.62.191 8333 port [tcp/*] succeeded!
admin ~  ฿  nc -vz  106.68.62.191 12345
nc: connect to 106.68.62.191 port 12345 (tcp) failed: Connection timed out

But you indicate you get 'success' for all ports. That should not happen.

Try the verbose (-zv) option on a closed port.

from raspibolt.

Stadicus avatar Stadicus commented on May 27, 2024

grafik

Ok, works great! Was not aware that the return value needs to be printed...

from raspibolt.

Stadicus avatar Stadicus commented on May 27, 2024

Any special reason you went with the == operator? I get the following error message:

grafik
./20-raspibolt-welcome: 117: [: 0: unexpected operator

When using the normal = operator, it works fine.
grafik

from raspibolt.

Stadicus avatar Stadicus commented on May 27, 2024

Updated the welcome script, thanks @robclark56!
PR #121

from raspibolt.

Janaka-Steph avatar Janaka-Steph commented on May 27, 2024

Hello @Stadicus @robclark56 !
I have some issues checking the public availability of my node (on testnet) with nc -vz IP PORT. As my node try to access my public IP address from behind a NAT, he got confused. This is a classic networking problem.

Reading this blog post System: Accessing Public IP address from behind NAT I found what I first thought was a solution, which is adding a rule in iptables to convert my public IP to my local IP.
$ sudo iptables -A INPUT -p tcp --src 85.220.240.110 --dport 22 -j ACCEPT

$ sudo iptables -L -t nat
Chain OUTPUT (policy ACCEPT)
target       prot    opt          source                 destination
DNAT       all        --            thundroid            85.220.240.110            to:192.168.1.104

It seems to work but in fact it is not checking anything because the request never really leave my local network. So not a proper solution.

It seems that this nc call works seamlessly for some people but I can't figure out why it doesn't work for me. Any ideas? Thank you.

from raspibolt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.