I need the DNS suffix of all my local interfaces on my PC.
Is there way how I can achieve this via Go?
Best case would be for any OS
Necessary: working on Windows
I have tried net.Inferfaces() and all the net commands but I haven't found anything regarding the DNS server.
EDIT
I have found the solution for the Windows-specific version but it would be interesting if there is anything that works for Linux and macOS too.
I don't think there is a solution that work for any OS. In Linux the DNS suffix is not interface specific but system wide, it is configured in /etc/resolv.conf. Here is an excerpt from the man page:
search Search list for host-name lookup.
By default, the search list contains one entry, the local domain name. It is determined from the local hostname returned by gethostname(2); the local domain name is taken to be everything after the first '.'. Finally, if the hostname does not contain a '.', the root domain is assumed as the
local domain name.
This may be changed by listing the desired domain search path following the search keyword with spaces or tabs separating the names. Resolver queries having fewer than ndots dots (default is 1) in them will be attempted using each component of the search path in turn until a match is found.
For environments with multiple subdomains please read options ndots:n below to avoid man-in-the-middle attacks and unnecessary traffic for the root-dns-servers. Note that this process may be slow and will generate a lot of network traffic if the servers for the listed domains are not local, and
that queries will time out if no server is available for one of the domains.
If there are multiple search directives, only the search list from the last instance is used.
The net package standard library parses this file to get the DNS config, so the DNS resolver should behave as expected, however, the parsing functionality is not exposed.
The libnetwork.GetSearchDomains func in the libnetwork library should be able to help you out. If there are no search entries in /etc/resolv.conf, you should use the hostname, which can be gotten with the os.Hostname func.
I believe this also works for FreeBSD and Mac OS since they are both "UNIX like". But I am not 100% sure.
Related
I am setting up greenplum 3 node cluster for POC while checking installation steps I found that hostfile_exkeys file have to be in master node.
Can anyone tell me where I should create this file location, node etc?
And most important what to put in this?
You create hostfile_exkeys on the Master. It isn't needed on the other hosts. You can put it in /home/gpadmin or anywhere that is convenient for you.
You put the three hostnames for your POC in this file. Example:
mdw
sdw1
sdw2
This is documented pretty well here: https://gpdb.docs.pivotal.io/5120/install_guide/prep_os_install_gpdb.html
You can also run a POC in the cloud. Greenplum is available in AWS, Azure, and GCP. It does all of the configuration for you. You can even use the BYOL product listings for 90 days for free to evaluate the product or you can use the Hourly billed products to get support while you evaluate the product.
There are examples in the utililty reference for gpssh-exkeys documentation but, in general, you should put in all the hostnames in your cluster. If there a multiple network-interfaces, those can go in instead.
I generally put this file either in /home/gpadmin or /home/gpadmin/gpconfigs (good place to keep all files for initial setup and initialization).
Your file will look something like (one name per line):
mdw
sdw1
sdw2
If there are 2 network interfaces, it might look something like:
mdw
mdw-1
mdw-2
sdw1
sdw1-1
sdw1-2
sdw2
sdw2-1
sdw2-2
Your /etc/hosts file (on all server) should include the IP addresses for all the interfaces and their names, so this file should match those names listed in /etc/hosts.
This is primarily to allow the master to exchange ssh keys with all hosts so it is always password-less login to the hosts. After you have this file set up, you will run (example):
gpssh-exkeys -f /home/gpadmin/gpconfigs/yourhostfilename
I hope this helps.
We have a number of (developer) existDb database servers, and some staging/production servers.
Each have their own configuration, that are slightly different.
We need to select which configuration to load and use in queries.
The configuration is to be stored in an XML file within the repository.
However, when syncing the content of the servers, a single burnt-in XML file is not sufficient, since it is overwritten during copying from the other server.
For this, we need the physical name of the actual database server.
The only function found, request:get-server-name that is not quite stable since a single eXist server can be accessed through a number of various (localhost, intranet or external) URLs. However, that leads to unnecessary duplication of the configuration, one for each external URL...
(Accessing some local files in the file system is not secure and not fast.)
How to get the physical name of the existDb server from XQuery?
I m sorry but I don't fully understand your question, are you talking about exist's default conf.xml or your own configuration file that you need to store in a VCS repo? Should the xquery be executed on one instance and trigger an event in all others, or just some, or...? Without some code it is difficult to see why and when something gets overwritten.
you could try console:jmx-token which does not vary depending on URL (at least it shouldn't)
Also you might find it much easier to use a docker based approach. Either with multiple instances coordinated via docker-compose or to keep the individual configs from not interfering with each other when moving from dev to staging to production https://github.com/duncdrum/exist-docker
If I understand correctly, you basically want to be able to get the hostname or the IP address of a server from XQuery. If the functions in the XQuery Request module are not doing as you wish, then another option would be to set a Java System Property when starting eXist-db. This system property could be the internal DNS name or IP of your server, for example: -Dour-server-name=server1.mydomain.com
From XQuery you could then read that Java System property using util:system-property("our-server-name").
I have set up a connection with a rather large https server and I am able to download files if I know their name and location.
However, what I would like to do is search through the https file server and only pull out html files. I know how to do this in normal directories, but is there a way to list out files and directories in an https file server kinda like you would do an ls or dir?
I am unfamiliar with http servers in general so explanations are appreciated.
Thanks!
To list files, or be able to access them using HTTP from that list, you have to have a CGI, or some sort of plugin, that will give you a listing of the directories available.
That isn't something that is allowed by default as it can be a major security hole on a system. Imagine the problems someone could cause if they could browser through the /etc hierarchy on a *nix system and retrieve the password information, or through database files, etc.
So, by default no browsing of the file system is allowed. You can enable that many different ways, depending on the HTTPd server and the modules supplied with it or that have been added.
Writing such an interface isn't that hard either, but its better to rely on pre-built wheels, rather than reinvent your own.
I've an application running on a dev server and connecting to a dev-db hosting an oracle instance.
Now i'm deploying the on a prod/prod-db machine
Since the dev-db url is hardcoded inside the java code, the just-copied binaries still points to dev-db. As a quick warkaround i added a line in Windows Host file on prod so that dev-db now points to prod-db IP address. It's work, but i'm not very satisfied of this global-scope solution.
I was wondering if exits a way to make a hosts file "private" for a certain environments ie. only valid in the scope of my running application
No, there's no way to do this, and it's a bad approach anyway.
You should instead fix the real problem, which is the hard-coding of the address inside your java code. Put such things in a properties file, and use a different properties file for production.
I am attempting to query a set of SRV records using the naked host name (e.g. _service._proto) however this fails unless I also include the domain name. This is strange because other tools such as nslookup work fine and also using the same API call to query A records works fine with naked host names.
dsRet = DnsQuery("_service._udp",DNS_TYPE_SRV,DNS_QUERY_STANDARD,NULL,&pQueryResultsSet,NULL);//==DNS_ERROR_RCODE_NAME_ERROR
dsRet = DnsQuery("_service._udp",DNS_TYPE_TEXT,DNS_QUERY_STANDARD,NULL,&pQueryResultsSet,NULL);//==DNS_ERROR_RCODE_NAME_ERROR
dsRet = DnsQuery("_service._udp.example.com",DNS_TYPE_SRV,DNS_QUERY_STANDARD,NULL,&pQueryResultsSet,NULL);//==ERROR_SUCCESS
dsRet = DnsQuery("_service._udp.example.com",DNS_TYPE_TEXT,DNS_QUERY_STANDARD,NULL,&pQueryResultsSet,NULL);//==ERROR_SUCCESS
dsRet = DnsQuery("collector",DNS_TYPE_A,DNS_QUERY_STANDARD,NULL,&pQueryResultsSet,NULL); //==ERROR_SUCCESS
I can of course query the system to get the primary domain name and maybe even all of the configured search domains but I'm pretty sure I shouldn't have to do that. I can find very little reference to the Windows DNS APIs out there so I'm wondering if there is a better way to query TXT and SRV records. Does anyone have any experience with this under Windows?
Thanks for any suggestions,
Robert
The reason that it works under nslookup is that windows is performing all the searches using the domain suffixes that it is configured with. To see this in action start up nslookup and then issue the "set debug" command. Now perform your search and you will see the requests and responses send and received by your machine. There will be an unanaswered one for the "naked host name" before one of the configured domain suffixes is appended and matched.
Hope that this helps.
Jonathan
Here is a free DNS client library that you can use to query the DNS for different types of query: http://www.simpledns.com/dns-client-lib.aspx also http://arsofttoolsnet.codeplex.com