MCPcopy Create free account
hub / github.com/LUX-Core/lux / Discover

Function Discover

src/net.cpp:1838–1878  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1836}
1837
1838void static Discover(boost::thread_group& threadGroup) {
1839 if (!fDiscover)
1840 return;
1841
1842#ifdef WIN32
1843 // Get local host IP
1844 char pszHostName[256] = "";
1845 if (gethostname(pszHostName, sizeof(pszHostName)) != SOCKET_ERROR) {
1846 vector<CNetAddr> vaddr;
1847 if (LookupHost(pszHostName, vaddr, 0, true)) {
1848 for (const CNetAddr& addr : vaddr) {
1849 if (AddLocal(addr, LOCAL_IF))
1850 LogPrintf("%s: %s - %s\n", __func__, pszHostName, addr.ToString());
1851 }
1852 }
1853 }
1854#else
1855 // Get local host ip
1856 struct ifaddrs* myaddrs;
1857 if (getifaddrs(&myaddrs) == 0) {
1858 for (struct ifaddrs* ifa = myaddrs; ifa != NULL; ifa = ifa->ifa_next) {
1859 if (ifa->ifa_addr == NULL) continue;
1860 if ((ifa->ifa_flags & IFF_UP) == 0) continue;
1861 if (strcmp(ifa->ifa_name, "lo") == 0) continue;
1862 if (strcmp(ifa->ifa_name, "lo0") == 0) continue;
1863 if (ifa->ifa_addr->sa_family == AF_INET) {
1864 struct sockaddr_in* s4 = (struct sockaddr_in*)(ifa->ifa_addr);
1865 CNetAddr addr(s4->sin_addr);
1866 if (AddLocal(addr, LOCAL_IF))
1867 LogPrintf("%s: IPv4 %s: %s\n", __func__, ifa->ifa_name, addr.ToString());
1868 } else if (ifa->ifa_addr->sa_family == AF_INET6) {
1869 struct sockaddr_in6* s6 = (struct sockaddr_in6*)(ifa->ifa_addr);
1870 CNetAddr addr(s6->sin6_addr);
1871 if (AddLocal(addr, LOCAL_IF))
1872 LogPrintf("%s: IPv6 %s: %s\n", __func__, ifa->ifa_name, addr.ToString());
1873 }
1874 }
1875 freeifaddrs(myaddrs);
1876 }
1877#endif
1878}
1879
1880void StartNode(boost::thread_group& threadGroup, CScheduler& scheduler) {
1881 uiInterface.InitMessage(_("Loading addresses..."));

Callers 11

StartNodeFunction · 0.85
lux_de.tsFile · 0.85
lux_fr.tsFile · 0.85
lux_en.tsFile · 0.85
lux_ja.tsFile · 0.85
lux_ca.tsFile · 0.85
lux_ro_RO.tsFile · 0.85
lux_it.tsFile · 0.85
lux_pt.tsFile · 0.85
lux_zh_TW.tsFile · 0.85
lux_da.tsFile · 0.85

Calls 3

LookupHostFunction · 0.85
AddLocalFunction · 0.85
ToStringMethod · 0.45

Tested by

no test coverage detected