#include "prog-constains.h" #include "fs-tools.h" #include #include #include #include #if defined(Q_OS_LINUX) #include #include #elif defined(Q_OS_MACOS) #include #elif defined(Q_OS_WIN) #include #endif static QString getExecutableDir() { #if defined(Q_OS_LINUX) char path[PATH_MAX]; ssize_t len = readlink("/proc/self/exe", path, sizeof(path) - 1); if (len != -1) { path[len] = '\0'; return QFileInfo(QString::fromLocal8Bit(path)).absolutePath(); } #elif defined(Q_OS_MACOS) uint32_t size = 0; _NSGetExecutablePath(NULL, &size); char *path = new char[size]; if (_NSGetExecutablePath(path, &size) == 0) { QString result = QFileInfo(QString::fromLocal8Bit(path)).absolutePath(); delete[] path; return result; } delete[] path; #elif defined(Q_OS_WIN) wchar_t path[MAX_PATH]; GetModuleFileNameW(NULL, path, MAX_PATH); return QFileInfo(QString::fromWCharArray(path)).absolutePath(); #endif return QDir::currentPath(); // fallback } const QString __dirname = getExecutableDir(); const QString VERSION = "0.0.1 beta"; const QString JAVA_INSTALL_PATH = QDir(__dirname).filePath("java"); const QString I2P_INSTALL_PATH = QDir(__dirname).filePath("i2p"); const QString TEMP_PATH = QDir(__dirname).filePath("temp"); const QString WIKI_URL = "https://git.fullgream.tech/Conan-Craft/launcher/wiki/"; // TODO: Edit it later const QString DEFAULT_I2PD_CONF = "## Configuration file for a typical i2pd user\n## See https://i2pd.readthedocs.io/en/latest/user-guide/configuration/\n## for more options you can use in this file.\n\n## Lines that begin with \"## \" try to explain what's going on. Lines\n## that begin with just \"#\" are disabled commands: you can enable them\n## by removing the \"#\" symbol.\n\n## Tunnels config file\n## Default: ~/.i2pd/tunnels.conf or /var/lib/i2pd/tunnels.conf\n# tunconf = /var/lib/i2pd/tunnels.conf\n\n## Tunnels config files path\n## Use that path to store separated tunnels in different config files.\n## Default: ~/.i2pd/tunnels.d or /var/lib/i2pd/tunnels.d\n# tunnelsdir = /var/lib/i2pd/tunnels.d\n\n## Path to certificates used for verifying .su3, families\n## Default: ~/.i2pd/certificates or /var/lib/i2pd/certificates\n# certsdir = /var/lib/i2pd/certificates\n\n## Where to write pidfile (default: /run/i2pd.pid, not used in Windows)\n# pidfile = /run/i2pd.pid\n\n## Logging configuration section\n## By default logs go to stdout with level 'info' and higher\n## For Windows OS by default logs go to file with level 'warn' and higher\n##\n## Logs destination (valid values: stdout, file, syslog)\n## * stdout - print log entries to stdout\n## * file - log entries to a file\n## * syslog - use syslog, see man 3 syslog\n# log = file\n## Path to logfile (default: autodetect)\n# logfile = /var/log/i2pd/i2pd.log\n## Log messages above this level (debug, info, *warn, error, critical, none)\n## If you set it to none, logging will be disabled\n# loglevel = warn\n## Write full CLF-formatted date and time to log (default: write only time)\n# logclftime = true\n\n## Daemon mode. Router will go to background after start. Ignored on Windows\n## (default: true)\n# daemon = true\n\n## Specify a family, router belongs to (default - none)\n# family =\n\n## Network interface to bind to\n## Updates address4/6 options if they are not set\n# ifname =\n## You can specify different interfaces for IPv4 and IPv6\n# ifname4 =\n# ifname6 =\n\n## Local address to bind transport sockets to\n## Overrides host option if:\n## For ipv4: if ipv4 = true and nat = false\n## For ipv6: if 'host' is not set or ipv4 = true\n# address4 =\n# address6 =\n\n## External IPv4 or IPv6 address to listen for connections\n## By default i2pd sets IP automatically\n## Sets published NTCP2v4/SSUv4 address to 'host' value if nat = true\n## Sets published NTCP2v6/SSUv6 address to 'host' value if ipv4 = false\n# host = 1.2.3.4\n\n## Port to listen for connections\n## By default i2pd picks random port and listens on it.\n## If you want to change the port, you MUST pick a random number too,\n## don't just uncomment this\n# port = 4567\n\n## Enable communication through ipv4 (default: true)\nipv4 = true\n## Enable communication through ipv6 (default: false)\nipv6 = false\n\n## Bandwidth configuration\n## L limit bandwidth to 32 KB/sec, O - to 256 KB/sec, P - to 2048 KB/sec,\n## X - unlimited\n## Default is L (regular node) and X if floodfill mode enabled.\n## If you want to share more bandwidth without floodfill mode, uncomment\n## that line and adjust value to your possibilities. Value can be set to\n## integer in kilobytes, it will apply that limit and flag will be used\n## from next upper limit (example: if you set 4096 flag will be X, but real\n## limit will be 4096 KB/s). Same can be done when floodfill mode is used,\n## but keep in mind that low values may be negatively evaluated by Java\n## router algorithms.\n# bandwidth = L\n## Max % of bandwidth limit for transit. 0-100 (default: 100)\n# share = 100\n\n## Router will not accept transit tunnels, disabling transit traffic completely\n## (default: false)\n# notransit = true\n\n## Router will be floodfill (default: false)\n## Note: that mode uses much more network connections and CPU!\n# floodfill = true\n\n## For places with limited connectivity (default: false)\n# stan = true\n\n[ntcp2]\n## Enable NTCP2 transport (default: true)\n# enabled = true\n## Publish address in RouterInfo (default: true)\n# published = true\n## Port for incoming connections (default is global port option value)\n# port = 4567\n\n[ssu2]\n## Enable SSU2 transport (default: true)\n# enabled = true\n## Publish address in RouterInfo (default: true)\n# published = true\n## Port for incoming connections (default is global port option value)\n# port = 4567\n\n[http]\n## Web Console settings\n## Enable the Web Console (default: true)\n# enabled = true\n## Address and port service will listen on (default: 127.0.0.1:7070)\n# address = 127.0.0.1\n# port = 7070\n## Path to web console (default: /)\n# webroot = /\n## Enable Web Console authentication (default: false)\n## You should not use Web Console via public networks without additional encryption.\n## HTTP authentication is not encryption layer!\n# auth = true\n# user = i2pd\n# pass = changeme\n## Select webconsole language\n## Currently supported english (default), afrikaans, armenian, chinese, czech, french,\n## german, italian, polish, portuguese, russian, spanish, turkish, turkmen, ukrainian\n## and uzbek languages\n# lang = english\n\n[httpproxy]\n## Enable the HTTP proxy (default: true)\n# enabled = true\n## Address and port service will listen on (default: 127.0.0.1:4444)\n# address = 127.0.0.1\n# port = 4444\n## Optional keys file for proxy local destination (default: transient-proxy)\n## \"Transient\" means it changes on every new app launch\n## If you want not change address then set like http-proxy-keys.dat\n# keys = http-proxy-keys.dat\n## Enable address helper for adding .i2p domains with \"jump URLs\" (default: true)\n## You should disable this feature if your i2pd HTTP Proxy is public,\n## because anyone could spoof the short domain via addresshelper and forward other users to phishing links\n# addresshelper = true\n## Address of a proxy server inside I2P, which is used to visit regular Internet\n# outproxy = http://false.i2p\n## httpproxy section also accepts I2CP parameters, like \"inbound.length\" etc.\n\n[socksproxy]\n## Enable the SOCKS proxy (default: true)\n# enabled = true\n## Address and port service will listen on (default: 127.0.0.1:4447)\n# address = 127.0.0.1\n# port = 4447\n## Optional keys file for proxy local destination (default: transient-proxy)\n## \"Transient\" means it changes on every new app launch\n## If you don't want the address to change, set a file name like socks-proxy-keys.dat\n# keys = socks-proxy-keys.dat\n## Socks outproxy. Example below is set to use Tor for all connections except i2p\n## Enable SOCKS outproxy (works only with SOCKS4, default: false)\n# outproxy.enabled = false\n## Address and port of outproxy\n# outproxy = 127.0.0.1\n# outproxyport = 9050\n## socksproxy section also accepts I2CP parameters, like \"inbound.length\" etc.\n\n[sam]\n## Enable the SAM bridge (default: true)\n# enabled = false\n## Address and ports service will listen on (default: 127.0.0.1:7656, udp: 7655)\n# address = 127.0.0.1\n# port = 7656\n# portudp = 7655\n\n[bob]\n## Enable the BOB command channel (default: false)\n# enabled = false\n## Address and port service will listen on (default: 127.0.0.1:2827)\n# address = 127.0.0.1\n# port = 2827\n\n[i2cp]\n## Enable the I2CP protocol (default: false)\n# enabled = false\n## Address and port service will listen on (default: 127.0.0.1:7654)\n# address = 127.0.0.1\n# port = 7654\n\n[i2pcontrol]\n## Enable the I2PControl protocol (default: false)\n# enabled = false\n## Address and port service will listen on (default: 127.0.0.1:7650)\n# address = 127.0.0.1\n# port = 7650\n## Authentication password (default: itoopie)\n# password = itoopie\n\n[precomputation]\n## Enable or disable elgamal precomputation table\n## By default, enabled on i386 hosts\n# elgamal = true\n\n[upnp]\n## Enable or disable UPnP: automatic port forwarding (enabled by default in WINDOWS, ANDROID)\n# enabled = false\n## Name i2pd appears in UPnP forwardings list (default: I2Pd)\n# name = I2Pd\n\n[meshnets]\n## Enable connectivity over the Yggdrasil network (default: false)\n# yggdrasil = false\n## You can bind address from your Yggdrasil subnet 300::/64\n## The address must first be added to the network interface\n# yggaddress =\n\n[reseed]\n## Options for bootstrapping into I2P network, aka reseeding\n## Enable reseed data verification (default: true)\nverify = true\n## URLs to request reseed data from, separated by comma\n## Default: \"mainline\" I2P Network reseeds\n# urls = https://reseed.i2p-projekt.de/,https://i2p.mooo.com/netDb/,https://netdb.i2p2.no/\n## Reseed URLs through the Yggdrasil, separated by comma\n# yggurls = http://[324:71e:281a:9ed3::ace]:7070/\n## Path to local reseed data file (.su3) for manual reseeding\n# file = /path/to/i2pseeds.su3\n## or HTTPS URL to reseed from\n# file = https://legit-website.com/i2pseeds.su3\n## Path to local ZIP file or HTTPS URL to reseed from\n# zipfile = /path/to/netDb.zip\n## If you run i2pd behind a proxy server, set proxy server for reseeding here\n## Should be http://address:port or socks://address:port\n# proxy = http://127.0.0.1:8118\n## Minimum number of known routers, below which i2pd triggers reseeding (default: 25)\n# threshold = 25\n## Follow redirects when reseeding from URLs (default: false)\n# followredirect = false\n\n[addressbook]\n## AddressBook subscription URL for initial setup\n## Default: reg.i2p at \"mainline\" I2P Network\n# defaulturl = http://shx5vqsw7usdaunyzr2qmes2fq37oumybpudrd4jjj4e4vk4uusa.b32.i2p/hosts.txt\n## Optional subscriptions URLs, separated by comma\n# subscriptions = http://reg.i2p/hosts.txt,http://identiguy.i2p/hosts.txt,http://stats.i2p/cgi-bin/newhosts.txt\n\n[limits]\n## Maximum active transit sessions (default: 25000)\n## This value is doubled if floodfill mode is enabled!\n# transittunnels = 25000\n## Limit number of open file descriptors (0 - use system limit)\n# openfiles = 0\n## Maximum size of corefile in Kb (0 - use system limit)\n# coresize = 0\n\n[trust]\n## Enable explicit trust options. (default: false)\n# enabled = true\n## Make direct I2P connections only to routers in specified Family.\n# family = MyFamily\n## Make direct I2P connections only to routers specified here. Comma separated list of base64 identities.\n# routers =\n## Should we hide our router from other routers? (default: false)\n## Note: this is not an overall hidden mode\n# hidden = true\n\n[exploratory]\n## Exploratory tunnels settings with default values\n# inbound.length = 2\n# inbound.quantity = 3\n# outbound.length = 2\n# outbound.quantity = 3\n\n[persist]\n## Save peer profiles on disk (default: true)\n# profiles = true\n## Save full addresses on disk (default: true)\n# addressbook = true\n\n"; const QString DEFAULT_TUNNELS_CONF = "[IRC-ILITA]\ntype = client\naddress = 127.0.0.1\nport = 6668\ndestination = irc.ilita.i2p\ndestinationport = 6667\nkeys = irc-keys.dat\ni2p.streaming.profile=2"; void debugVariables () { qDebug() << "====================="; qDebug() << " VARIABLES "; qDebug() << "====================="; qDebug() << "__dirname" << __dirname; qDebug() << "JAVA_INSTALL_PATH" << JAVA_INSTALL_PATH; qDebug() << "I2P_INSTALL_PATH" << I2P_INSTALL_PATH; qDebug() << "TEMP_PATH" << TEMP_PATH; qDebug() << "WIKI_URL" << WIKI_URL; }