Is there a way to use the whois gem (https://github.com/weppos/whois) with a -h flag? I am looking to run whois queries against a specific database host in my rails project (e.g. whois -h whois.myserver.example google.com)
If not, are there other ways to accomplish this?
From the documentation at https://www.rubydoc.info/gems/whois/Whois/Client
Parameters:
settings (Hash) (defaults to: {}) —
Hash of settings to customize the client behavior.
Options Hash (settings):
:timeout (Integer, nil) — default: DEFAULT_TIMEOUT —
The timeout for a WHOIS query, expressed in seconds.
:bind_host (String) — default: nil —
Providing an IP address or hostname will bind the Socket connection to the specific local host.
:bind_port (Fixnum) — default: nil —
Providing port number will bind the Socket connection to the specific local port.
:host (String, nil) — default: nil —
The server host to query. Leave it blank for intelligent detection.
So
client = Whois::Client.new(:host => "whois.myserver.example")
should be what you need.
No idea if you need to change the port too.
Related
I'm trying to get the IPv4 from the URL below:
use url::{Url, Host};
use std::net::{SocketAddr, IpAddr};
fn main () {
let url = Url::parse("rtsp://admin:12345#192.168.1.178:10554/tcp/av0_0").unwrap();
let port = url.port().unwrap_or(554);
let ip_address = match url.host() {
Some(Host::Ipv4(ipv4)) => SocketAddr::new(IpAddr::V4(ipv4), port),
Some(Host::Ipv6(ipv6)) => SocketAddr::new(IpAddr::V6(ipv6), port),
None => panic!("missing host"),
_ => panic!(format!("only IP hosts are accepted. Your host: {:?}", url.host()))
};
println!("{}", ip_address);
}
Playground
but it panics:
thread 'main' panicked at 'only IP hosts are accepted. Your host: Some(Domain("192.168.1.178"))', src/main.rs:11:14
What is wrong? The host is clearly an ip address.
Looking a the bug tracker, I found IP is not recognized in RTSP url.
The answer is apparently that url follows / implements the URL Standard (which makes sense as it was developed in the context of Servo), and the URL Standard only requires IPv4 address recognition of a select number of schemes because those schemes (apparently) handle IPv4 addresses specially: https://github.com/servo/rust-url/issues/577
Specifically: the special schemes are ftp, http, https, ws, wss (there's also file but it's its own category), and the differences in host representation are that:
a special scheme's host can be ipv4, ipv6, or domain
a non-special scheme's host can be ipv6, opaque, empty, or null
url will in fact parse ipv6 for non-special schemes, though everything else it just dumps into Some(Domain(...)) (or None).
Anyway this means that if you get a Domain result, you probably want to try and parse it as an IP.
Incidentally, you don't have to format! to format your panic messages, panic! will do that internally.
What is the format for the PostgreSQL connection string (URL postgres://...) when the host is not the localhost?
If you use Libpq binding for respective language, according to its documentation URI is formed as follows:
postgresql://[user[:password]#][netloc][:port][/dbname][?param1=value1&...]
Here are examples from same document
postgresql://
postgresql://localhost
postgresql://localhost:5432
postgresql://localhost/mydb
postgresql://user#localhost
postgresql://user:secret#localhost
postgresql://other#localhost/otherdb?connect_timeout=10&application_name=myapp
postgresql://localhost/mydb?user=other&password=secret
The following worked for me
const conString = "postgres://YourUserName:YourPassword#YourHostname:5432/YourDatabaseName";
DATABASE_URL=postgres://{user}:{password}#{hostname}:{port}/{database-name}
Here is the documentation for JDBC, the general URL is "jdbc:postgresql://host:port/database"
Chapter 3 here documents the ADO.NET connection string,
the general connection string is Server=host;Port=5432;User Id=username;Password=secret;Database=databasename;
PHP documentation us here, the general connection string is
host=hostname port=5432 dbname=databasename user=username password=secret
If you're using something else, you'll have to tell us.
the connection url for postgres
syntax:
"Server=host ipaddress;Port=5432;Database=dbname;User Id=userid;Password=password;
example:
"Server=192.168.1.163;Port=5432;Database=postgres;User Id=postgres;Password=root;
server.address=10.20.20.10
server.port=8080
database.user=username
database.password=password
spring.datasource.url=jdbc:postgresql://${server.address}/${server.port}?user=${database.user}&password=${database.password}
The connection string can also be retrieved programmatically from working DB connectors.
For instance I sometimes extract connection strings from SQLAlchemy's engine, like this:
> db_engine.url
postgres://{user}:{password}#{host}:{port}/{db_name}?sslmode=require
Some people seem to misread the database name as a server name and the host as a postgresql server? A host hosts a postgresql server that has a database. Or am I missing something.
postgresql://my_host/&server=my_postgresql_server?user=my_user&port=my_port&password=my_password&database=my_database
Example:
my_host: can be "localhost" (but that is not in the question) or an ip address of a host.
postgresql://my_host/&server=postgres?user=postgres&port=5432&password=postgres&database=test_db
Worked for me in Python with sqlalchemy and a postgresql localhost running. Needs sqlalchemy, postgresql, and psycopg2 to get it to work.
PS: The question is about a postgres://... URL, but this would not work here. Instead, you need postgresql, and what is run in the end in Python is dialect+driver (see Database URLs) = postgresql+psycopg2, without having to write it like this.
The general format of database url
DATABASE_URL=postgresql://username:password#host:port/dtabase_name
If you are using postgresql sql with asyncpg the database url would be
DATABASE_URL=postgresql+asyncpg://username:password#host:port/dtabase_name
Remember to never push your database password so you should use your DATABASE_URL in .env file
The port is optional if you use the default one
Like this you can connect both local and remote database think of that once you want to check an issue that occur in the remote deployed versions
ex of localhost DATABASE_URL would be
DATABASE_URL=postgresql+asyncpg://postgres:dina#localhost/mysens
If you deployed your database on Heroku and you want to connect it with your local app, go to Heroku Postgres installed add-on go to settings and click on view credential in Database Credentials and use the uri to connect to your database
DATABASE_URL=postgresql+asyncpg://sqnalxxxxxxxxx:160xxxx2bdd2942b26c93c392xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx#ec2-35-173-91-114.compute-1.amazonaws.com:5432/del6o4cjoqfsov
The new NBIOT demo modules from O2 - we are testing - they only accept an IP address as a broker host rather than URL [mqtt.googleapis.com]. If i run DNS lookup this is fine - but how stable is the IP address associated with the mqtt.googleapis.com ??
I have the DNS lookup here 74.125.201.206
How long will it remain stable / the same ??
stream {
upstream google_mqtt {
server mqtt.googleapis.com:8883;
}
server {
listen 8883;
proxy_pass google_mqtt;
}
}
Instead of the mqtt url i want to insert IP address
Why would you want to hard code the IP address? You are just setting yourself up for it to fail at the moment you can't fix it (e.g. while on vacation)
You shouldn't assume an IP address returned by a DNS query is good for any longer than the TTL value returned with the response.
Hostnames are a deliberate abstraction so you don't have to worry about if the IP address changes, be it due to a failure, maintenance, load balancing.
Just DON'T hardcode the IP address.
If the module you mentioned REALLY only accepts IP addresses then you need to raise a bug against the supplier saying this needs fixing, especially as this is for a field deployed device that you probably can't easily update once deployed.
I have created test bitcoins but how to deposit it in Peatio.
currencies.yml
- id: 2
key: satoshi
code: btc
symbol: "฿"
coin: true
quick_withdraw_max: 1000
rpc: http://test_user_123:ddd545a1142f7fd3e167cd60e60d0a67#127.0.0.1:18332
blockchain: https://testnet.smartbit.com.au/tx/e9d09a0401080e299c3871ba8e3bf537ab20734567cb86ea7a63d9a025b1a8f3
address_url: https://testnet.smartbit.com.au/address/msCgLuJQNiRnXEg9AJzgpzC1qxehFNWkfH
assets:
balance: 3333
accounts:
-
address: msCgLuJQNiRnXEg9AJzgpzC1qxehFNWkfH
bitcoin.conf
server=1
daemon=1
# If run on the test network instead of the real bitcoin network
testnet=1
# You must set rpcuser and rpcpassword to secure the JSON-RPC api
# Please make rpcpassword to something secure, `5gKAgrJv8CQr2CGUhjVbBFLSj29HnE6YGXvfykHJzS3k` for example.
# Listen for JSON-RPC connections on <port> (default: 8332 or testnet: 18332)
rpcuser=test_user_123
rpcpassword=ddd545a1142f7fd3e167cd60e60d0a67
rpcport=18332
# Notify when receiving coins
walletnotify=curl http://192.168.1.41:3000/payment_transaction/btc/%s
I am not able to see the balance in my bitcoin funds. What could be the reason for this?
Server trace:
Started GET "/payment_transaction/btc/dc06e9864d3114ea814118f6c9b578d52f67874477ff0b546e79b360775e1117" for 192.168.1.41 at 2017-10-25 18:57:00 +0530
ActionController::RoutingError (No route matches [GET] "/payment_transaction/btc/dc06e9864d3114ea814118f6c9b578d52f67874477ff0b546e79b360775e1117"):
lib/middleware/security.rb:11:in `call'
lib/middleware/i18n_js.rb:9:in `call'
I am not sure why, but it seems that the bitcoind was not configured properly.
So, first I did this manually. Find the transaction IDs you did and call it manually.
Either you can try using the same way you are doing, just make the curl as POST request. (For me, it's webhooks/tx) (https://github.com/peatio/peatio/issues/79#issuecomment-44631111)
Another option is, you can call /usr/local/sbin/rabbitmqadmin publish routing_key=peatio.deposit.coin payload='{"txid":"YOUR_TRANS_ID_HERE", "channel_key":"satoshi"}'
And it shows the balance now in peatio!
You are running peatio in testnet mode, If btc is deposited in the testnet address it won't reflect until and unless your blockchain server not sych with your peatio server.
Or check your blockchain server status is upto date
bitcoin-cli getblockcount
i want to check my server connection to know if its available or not to inform the user..
so how to send a pkg or msg to the server (it's not SQL server; it's a server contains some serviecs) ...
thnx in adcvance ..
With all the possibilities for firewalls blocking ICMP packets or specific ports, the only way to guarantee that a service is running is to do something that uses that service.
For instance, if it were a JDBC server, you could execute a non-destructive SQL query, such as select * from sysibm.sysdummy1 for DB2. If it's a HTTP server, you could create a GET packet for index.htm.
If you actually have control over the service, it's a simple matter to create a special sub-service to handle these requests (such as you send through a CHECK packet and get back an OKAY response).
That way, you avoid all the possible firewall issues and the test is a true end-to-end one. PINGs and traceroutes will be able to tell if you can get to the machine (firewalls permitting) but they won't tell you if your service is functioning.
Take this from someone who's had to battle the network gods in a corporate environment where machines are locked up as tight as the proverbial fishes ...
If you can open a port but don't want to use ping (i dont know why but hey) you could use something like this:
import socket
host = ''
port = 55555
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind((host, port))
s.listen(1)
while 1:
try:
clientsock, clientaddr = s.accept()
clientsock.sendall('alive')
clientsock.close()
except:
pass
which is nothing more then a simple python socket server listening on 55555 and returning alive