Code Monkey home page Code Monkey logo

masq-project / node Goto Github PK

View Code? Open in Web Editor NEW
166.0 11.0 27.0 86.54 MB

MASQ combines the benefits of VPN and Tor technology to create a superior next-generation privacy software, where users are rewarded for supporting an uncensored global web. Users gain privacy and anonymity online, while helping promote Internet Freedom.

Home Page: https://masq.ai

License: Other

Shell 0.55% Rust 99.41% Dockerfile 0.04%
masq-node internet vpn mesh-network rustlang

node's Introduction

MASQ Node masq-logo

ci-matrix GitHub Release Discord

MASQ Node combines the benefits of VPN and Tor technology, to create superior next-generation privacy software, where users are rewarded for supporting an uncensored, global Web. Users gain privacy and anonymity, while helping promote Internet Freedom.

Purpose

MASQ Node forms the foundation of the MASQ Network.

The MASQ Network is an open-source decentralized mesh-network (dMN) that allows any user to allocate spare computing resources to make the Internet a free and fair place for the entire world. It is a worldwide collection of Nodes that securely delivers content without the need of a VPN or Tor.

Because there's no single authority delivering or monitoring content, censorship and geo-restricted sites won't be an issue on the MASQ Network. It doesn't matter where you live or what content you're accessing, everyone in the world sees the exact same content.

MASQ Node software is what the average user runs to earn $MASQ utility tokens and dedicate some of their computers' resources toward the Network - users can be rewarded with $MASQ for each time they serve content.

MASQ Nodes work together through the mesh network to relay digital content. When a user requests a site, Nodes use a routing algorithm to find the most expedient and secure way to get the information to that user. Multiple Nodes work together to route a single request in order to maintain a necessary level of anonymity.

Important Note: Please remember that at the moment the MASQ Node is in development and is not clandestine. Your traffic can't be decrypted, and it is difficult to trace to you; but it is currently very easy for someone sniffing your Internet connection to tell that you're using some form of Peer networking. Please don't use it for any kind of sensitive traffic at this stage - MASQ Network and it's developers are not responsible for any activity, or loss incurred, while using this beta software.

Source

The MASQ project was forked from Substratum's Node project in order to carry on development after Substratum ceased operations in October of 2019. In 2021, Substratum's Node repositories were removed from GitHub, so the fork link with MASQ was broken, but all credit for the original idea, the original design, and the first two years of MASQ's development belongs to Substratum.

Running the MASQ Node

MASQ Node Knowledge Base

A Knowledge Base and testing resources are being refined for users with various levels of technical ability.

There you can find further information, guides and configuration examples for running MASQ Node from:

If you are interested in testing stages, speak to the team in the official Discord channel

MASQ Node Component README.md files

To help navigate the codebase, here are the README.md links for all documented components

Downloading Official Releases

Releases will appear on our GitHub page - click on the badge above for the latest stable beta build, or go to our Releases page

Downloading the Latest Build

If you want to try out the latest build, go to our GitHub Actions continuous integration page to see a list of builds. Look for the latest (uppermost) successful build: it'll have a white checkmark in a green circle next to it.

green check example

Click on that link and scroll to the end of the page. You'll see a set of three artifact packages, one for each platform MASQ supports.

artifact packages examples

Click the one that matches your platform; your browser will download a .zip file. Inside the .zip file are many things useful to developers, but you'll be interested in the executable binaries in /generated/bin.

contents of generated/bin

Make a directory somewhere on your system from which you'll run MASQ. You'll want to extract one or more files from /generated/bin in the .zip file into that directory.

The most important file is MASQNode, or MASQNode.exe if you're using Windows. Definitely extract that one. It contains the code for both the MASQ Node and the MASQ Daemon.

If you're using a graphical user interface for MASQ, that's all you'll need. If you're not, you'll probably also want masq, which is a command-line user interface.

If the regular network-proxy setup doesn't work for you, you might want dns_utility as well to make it easy to subvert your system's DNS configuration.

Finally, automap is a test utility used to check MASQ's automatic firewall penetration functionality against your particular router. Unless you've volunteered to help the MASQ dev team run tests, you won't need this.

Running from the Command Line

These instructions assume you have the MASQ Node executable but not the MASQ GUI. (If you do, consult the GUI documentation about starting the Node on our Testing Guides) You'll want to run the MASQ programs from wherever you expanded the /generated/bin path from the .zip file you downloaded.

There are a number of ways to run the Node, but the way you'll probably want to use is to make sure the MASQ Daemon is started first. If the Daemon is not running in the background already, open a terminal window and start it by typing

$ sudo nohup ./MASQNode --initialization &

if you're working in Linux or macOS, or

$ start /b MASQNode --initialization

if you're using Windows.

The Daemon's responsibility is to configure and start the Node. When it comes up, it sets up an initialization area that contains configuration data for the Node: some of it defaulted, some of it loaded from the environment, some loaded from a configuration file, if present, and the rest of it uninitialized. Before the Node is started, the configuration data in the Daemon's initialization area should be adjusted so that the Node has what it needs when it comes up.

If you have no GUI, the simplest way to do this is with the masq command-line user interface. Once you have the Daemon running, type

$ masq

at a handy command prompt. To learn how to use masq to set up and start the Node, type help at the masq> prompt, and pay special attention to the setup and start commands.

If this is the first time you're starting the Node, you may also be interested in set-password, create-wallets, and generate-wallets.

Supplying Configuration To MASQ Daemon

There are four ways to get configuration information into the initialization area of the MASQ Daemon on startup. In decreasing level of priority, these are:

  1. masq
  2. the Daemon's shell environment
  3. a configuration file
  4. defaults

Any piece of configuration information can be provided through any of these channels, with one exception: the path to the configuration file cannot be taken from the configuration file. (It can be provided there, but it will never be taken from there.) Configuration information provided in the configuration file will supersede defaults, information provided in the environment will supersede conflicting information provided in the configuration file, and information provided via the UI will supersede conflicting information from all the other sources.

UI

This is the easiest. In this file, our documentation of the configuration options shows you how to provide them to masq on the command line, either in interactive mode or in noninteractive mode. Keep in mind, though, that command lines tend to be preserved by the operating system for display to users who want to see process lists. Therefore, the command line may not be the best place to specify sensitive or secret configuration information. (Nothing prevents you from doing this, though, so be careful.)

Shell Environment

If you see that the UI accepts a command such as setup --clandestine-port 1234, then you can supply that same parameter in the environment by setting the MASQ_CLANDESTINE_PORT environment variable to 1234. Note that you need to remove the initial -- prefix, convert the name to all uppercase, change hyphens to underscores, and add a MASQ_ prefix to namespace the parameter against other applications that might look for a similar variable.

Configuration File

The configuration file, by default, resides in the data directory (see the --data-directory parameter for further information) and is named config.toml. If you leave the configuration file unspecified, this is where MASQ Node will look for it. If it's found, it will be used; if it's not, MASQ Node will act as though it had been found but empty. But if you want to use a different file, specify it either as --config-file in the Daemon setup or as MASQ_CONFIG_FILE in the environment. If you specify a relative filename, MASQ Node will look for the configuration file in the data directory; if you specify an absolute filename, MASQ Node will not use the data directory to find the configuration file.

The configuration file should be in TOML format. TOML is a competitor to other formats like JSON and YAML, but the MASQ Node uses only scalar settings, not arrays or tables. If you see that Daemon setup accepts a command such as setup --clandestine-port 1234, then you can supply that same parameter in the configuration file by adding the following line to it:

clandestine-port = "1234"

Note that you need to remove the initial -- prefix. All the configuration parameters will work if you supply their values as double-quoted strings, but if they're numeric values, you can supply them numerically as well--for example,

clandestine-port = 1234

Keep in mind that a configuration file is persistent information: anyone who has or can gain read access to the file can read whatever's in it, whether MASQ Node is running or not. Therefore, the configuration file may not be the best place to specify sensitive or secret configuration information. (Nothing prevents you from doing this, though, so be careful.)

Running a Decentralized MASQ Node Locally

Wallets

In order to run decentralized, MASQ Node needs at least an earning wallet (an Ethereum wallet into which other Nodes will make payments for the services your Node provides). If you plan to use your Node to consume data with a browser or other network application, it will also need to be configured with a funded consuming wallet (an Ethereum wallet from which it will make payments for the services other Nodes provide). If you want, you can use the same wallet for both earning and consuming, although this will allow an attacker to connect your network-forming Gossip traffic with your data traffic, if he wants.

MASQ only ever has to put money into your earning wallet, which means the Node only has to know its address. However, MASQ needs to pay money out of your consuming wallet; therefore the Node needs to know more about that one. Currently, we use the mnemonic seed, an optional "25th word" that serves the purpose of a password, and the derivation path.

If you route other people's traffic without having an earning wallet set up, a default earning wallet will be used, in which case the funds you earn will go to MASQ instead of to you: so unless you're in a philanthropic mood, you should be sure to set up or specify your earning wallet before you route data.

Password

The Node keeps a database on disk where it stores various things, like persistent configuration data and accounting information. In some cases, this information is sensitive, and if an attacker confiscated your computer and found the sensitive data, you or others could be put at risk. Therefore, all the security-sensitive data in the database is encrypted with a symmetric key. We call that key a password, and you're required to set it before you store any sensitive data in the database. There are no rules for how long the password must be or what it must contain--security of your data is your responsibility, not ours--but it needs to be present so that the database can be properly encrypted with it.

MASQ never stores the password anywhere on disk, only in memory; so A) you'll need to supply the password every time the Node starts, B) no one can tell you the password if you forget it, and C) forgetting it will mean that your database is useless, and you'll have to start it over.

Interactive masq vs Noninteractive masq

The masq command-line interface can run two ways. If you just type

$ ./masq

at a command prompt, you'll be shown a masq> prompt, and the system will await a series of masq commands from you. But if you type something like

$ ./masq setup --log-level debug --clandestine-port 1234

then masq will start up, execute the command you gave it, and immediately terminate.

This way, you can use interactive masq to give an impromptu series of commands to the Daemon and/or the Node, or you can write shell scripts to control the Daemon and/or the Node for special purposes, with those scripts containing noninteractive masq commands.

Daemon vs. Node

The MASQ Daemon and the MASQ Node are two different programs that share the same binary. If you start that binary with the --initialization parameter, it will become the Daemon; if you start it without the --initialization parameter, it will become the Node.

MASQ is designed to be very difficult to hack, but it's intended to go up against government-level attackers, so there's always the possibility that they could have the funding to do something we didn't anticipate. If an attacker figures out how to hack into a computer running MASQ, we think it's very important that at least he doesn't find himself hacked into a process running with administrative privilege.

Also, it's important that the user interface, whether command-line or graphical, be able to direct the Node to start without having administrative privilege. However, because of the network ports the Node has to initialize, it must at least start up with administrative privilege. It drops all special privileges before it reads any data from the network, though, so any attacker who manages to hack it over the network won't see those special privileges.

These two requirements led to the development of the MASQ Daemon. The Daemon should start up with administrative privilege at system-boot time, and keep running--with that privilege--until the computer shuts down. In return for being a long-running privileged process, the Daemon is forbidden from A) accessing the network in any way, and B) communicating with the Node in any way other than starting its process. As long as these limitations are respected, even someone who successfully hacks into the Node will not be able to hack into the privileged Daemon.

When the user interface (whether command-line or graphical) starts up, it connects first to the Daemon. There is a set of commands the UI can use to communicate with the Daemon, but this set is comparatively small. As long as the UI issues commands from that set, it will stay connected to the Daemon. At some point, the UI will probably issue a command the Daemon doesn't understand - if the Node is running then the Daemon will instruct the UI to drop its Daemon connection, create a new connection to the Node instead, and re-issue the unrecognized command so that the Node can execute it.

Thereafter, the UI will be connected to the Node. It will not connect again to the Daemon unless the Node shuts down or crashes; then the UI will fall back to the Daemon (if it's still running) or exit (if it's not).

Handy masq Subcommands

masq has quite a few subcommands that you can use, both interactively and noninteractively. The best way to find out about these subcommands is to type

$ ./masq --help

noninteractively at a shell-command prompt, or

masq> help

interactively at a masq prompt.

Neighbors

If you're starting the very first MASQ Node in a MASQ network, then you don't have to tell your Node about any preexisting network; instead, other people who want to join that MASQ Network will have to tell their Nodes about your Node, which means you'll need to give them your Node descriptor.

Otherwise, you'll need to specify --neighbors as part of your masq setup so that your Node will know how to join the network that is already in place.

However, if your machine has already recently been on the MASQ Network, and you're starting the Node up again, there's a chance that at least some of the Nodes that were recently your neighbors are still up and can be recontacted; in that case, the Daemon will read the Node descriptors of your former neighbors out of the database and pre-populate the --neighbors setup with them, and you might not have to enter anything manually.

Enabling Contact

In order to run decentralized, the MASQ Node must know the IP address others can use to contact it. Therefore, you must supply --ip.

Your home network is behind your internet provider's router and a public IP address. Other Nodes in the MASQ Network will contact your Node through your public IP address, requiring at least one port to be forwarded on your router. The MASQ Node Gossip protocol "gossips" to other Nodes the clandestine port you are listening on, and it is that port you will need to open. When your Node is started it will write its descriptor to the console and the log, giving the clandestine port it is using; you will need to forward that port from your router to your computer's IP address.

Forwarding ports on your router is somewhat technical. At a minimum, you should know how to log in to your router in order to make changes to its configuration. The process is interchangeably called forwarding a port, opening a port, or mapping a port, and may be labeled as such in the router's interface. Assigning a static IP address for your computer will make this process easier, as otherwise your IP address can change each time your computer restarts or you restart the network interface. There are many guides that you can find on the Internet by searching for "Port Forwarding" or "How to Port Forwarding". Here is an example: PortForward.com

More information on the operation, care, and feeding of the Neighborhood is available in the neighborhood_subproject.

Terminating a MASQ Node

Terminating a MASQ Node may be more of a process than you expect. There are three things to consider.

The most obvious is the MASQ Node itself. Terminating that is easy: just send it a shutdown message, with the GUI if you have it, or with masq like this:

$ ./masq shutdown

noninteractively, or if you're interactive,

masq> shutdown

However, if you were using your Node to access the Internet--that is, to consume--your computer's network stack is now missing an important component, and it won't work anymore until you reconfigure it to operate without the Node. If you configured your proxy settings to use the Node as an HTTP proxy, you'll want to disable them, or revert them back to what they were before you started the Node. If you're using DNS subversion, you'll want to revert that:

$ sudo ./dns_utility revert

Third, you'll probably want to close the hole or holes in your router's firewall. Don't leave them open against the next time you run: it's dangerous to leave open holes in your firewall to ports you're not actively using on purpose.

Errors

MASQ Node, like any other piece of software, can encounter obstacles it cannot overcome in the process of trying to do what you ask it to do. It needs to be able to tell you about these insurmountable obstacles, but it lives in a place that makes this difficult. If it were a Web browser, it would have a window on which to display error messages. If it were a Web server it could send data describing the errors to your browser to display. But it's neither of these things; instead, it's crowded into a place in the protocol stack where neither the browser nor the server expects it to exist.

Therefore, certain error messages are a bit awkward to display in the browser, especially if they involve TLS connections. Let's look at how MASQ Node deals with certain kinds of errors.

HTTP

An insecure HTTP connection is one that is based on a URL that begins with http:// (as opposed to https://). The fact that it is insecure means that MASQ Node (and every other process that handles the data) can intrude on the data stream and make your browser display whatever they want it to, which may or may not be related to what the server on the other end of the connection intended.

When errors occur, this is very useful for MASQ Node. If you request something from an HTTP server (and for some reason MASQ Node cannot relay your request to that server) or cannot relay the response from the server back to you, MASQ Node will instead impersonate the server and create a counterfeit response describing the error. This will be displayed to you instead of the server response it can't give you. (Don't worry: MASQ Node's impersonation of the server is deliberately very bad, so you can easily tell that the error is not coming from the server. You won't be misled). The error message will describe the problem and suggest ways it might be alleviated.

TLS

TLS (spoken over connections based on URLs that begin with https://) is a much more difficult beast. Once a TLS connection is set up between your browser and a server, MASQ Node cannot understand a single bit of the dataflow, and it cannot modify a single bit of it without your browser throwing red alerts and refusing to show you the modified data. This is good for you and your privacy, but it doesn't make it easy for MASQ Node to communicate with you via the browser.

There is a small exception.

Once a TLS connection is set up, it's completely secure. But while it's being set up, before the encrypted tunnel has been established, there's a little MASQ Node can do. Specifically, it can inject what's called a TLS Alert into the stream of data, as long as it is injected very early. This TLS Alert has a single byte that MASQ Node can use to tell you about problems it has relaying your data. There are a number of predefined values this byte can take on, and MASQ Node has to pick one of these values: it can't make up its own.

If your browser is trying to load a page when the error occurs, you'll see a cryptic message in its window telling you that you're not going to get what you're after. The exact wording of the error depends on the exact type of the TLS Alert. If your browser is trying to communicate in the background when the error occurs, you probably won't see it on the screen; but if the browser stops responding, you can open its developer tools and check the JavaScript console; if MASQ Node sent a TLS Alert, you'll see it there.

Since the concerns of the MASQ Node aren't precisely the same as the concerns of a TLS endpoint, the correspondence can't always be made exact, so here are some specific TLS Alert values that MASQ Node produces in specific situations.

  • Routing Failure - internal_error: If your Node is not yet "warmed up" enough in the MASQ Network to see a large enough neighborhood to be able to create a clandestine route that meets your specifications, it will raise a TLS internal_error Alert. This will probably be displayed by your browser as some sort of protocol error--which, strictly speaking, it is. If this happens, just wait awhile for your Node and the MASQ Network to Gossip with each other and spread around the necessary information. Then try reloading the page.

  • DNS Resolution Failure - unrecognized_name: Even though you contact websites at names like google.com and twitter.com, the real Internet operates on the basis of IP addresses (like 172.217.6.14 and 31.13.66.35). Before it's useful for retrieving data, your server name has to be translated into an IP address. This is the job of a DNS server. Much of Internet censorship consists of crippling the DNS servers you have available to you so that they can't give you the correct IP address for the server name you're seeking. MASQ Node captures the DNS queries your browser makes and forwards them across the MASQ Network to some other Node that hopefully has access to a non-censored DNS server that does know the IP address you want. But this is a complex task and it may fail. For example, perhaps you typed the server name wrong, and nobody knows an IP address it matches. Or perhaps your MASQ Node guessed wrong, and the exit Node to which it forwarded your DNS query is also handicapped by a censored DNS and can't find it either. In either case, MASQ Node will send your browser a TLS unrecognized_name alert, which your browser will probably present to you as some form of can't-find-host error. If you reload the page, MASQ Node will try to select a different exit Node, if available--one that hasn't failed to resolve a DNS query--for the next attempt, which might bring you better fortune. Of course, if you have typed the name wrong, just reloading the page will take another innocent exit Node out of circulation and make it even harder for you to get where you want to go.

Disclosure

We run tests on every push to master on these platforms:

  • Ubuntu 20.04 LTS Desktop 64-bit
  • MacOS High Sierra (currently testing on Big Sur)
  • Windows 10 64-bit

MASQ Node doesn't reliably build on 32-bit Windows due to issues with the build tools for that platform. We recommend using a 64-bit version to build.

We do plan to release binaries that will run on 32-bit Windows, but they will likely be built on 64-bit Windows.

Copyright (c) 2019-2022, MASQ Network

Copyright (c) 2017-2019, Substratum LLC and/or its affiliates. All rights reserved.

node's People

Contributors

bertllll avatar clandest avatar czarte avatar darthstrom avatar dnwiebe avatar dyercode avatar finsaasgh avatar justinfinley avatar k3vinw avatar kauri-hero avatar masqrauder avatar something avatar steveswing avatar substratumservices avatar syther007 avatar udioeater avatar utkarshg6 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node's Issues

Free World Bit from locale

Write some platform-dependent code to get the current locale's language/country code from the operating system. (For Linux and Mac, it's in the $LANG environment variable; for Windows, probably somewhere in the Registry. Look at dns_utility for example Registry code.) Search for the country code in a list of non-Free-World countries to set the Free World bit.

Finish Proxy Mode

Make sure the Node is tunneling TLS proxy requests through HTTP properly using the HTTP CONNECT method.

Also, review the rules for HTTP proxies and make sure the Node is following enough of them.

Inaccessible List: Compilation

Add a message for the Proxy Client to send to the Neighborhood, with another inaccessible hostname to add to the list. Have the Neighborhood generate a debug log whenever that message arrives, showing the full list of hostnames now known to be locally inaccessible.

GL/TLD: Geolocation Database

Build an IP-address-to-country-code geolocation database into the SubstratumNode. Use it during startup on the Node's public IP address to identify the Node's country. Print the country to the console as part of the startup message.

Note: this should probably not be an actor.

Inaccessible List: Hard Limit

Add a reasonable hard limit on the number of unreachable nodes in the list. When the list overflows, replace the oldest hostnames with the newest ones. When accepting Gossip, reject nodes with too many unreachables. (Can't just truncate their lists: eventually the lists will be signed and unmodifiable.)

Design And Build Malefactor Banning for the Database

Malefactors should be bannable by IP address, Node public key, and earning wallet.

Bans by IP should be temporary (probably hours) in case the IP is transferred to another user who isn't a malefactor.

Bans by public key and wallet should be theoretically permanent, but truly permanent bans raise the specter of a denial-of-service attack by filling up the database with malefactor bans so that each hop is significantly delayed while the Node looks through its list of bans to see whether the purveyor of the current CORES package is among them. Therefore even public-key and wallet bans should probably be time-limited, although more generously than IP bans.

Create a database table or tables to persist malefactor bans from run to run (don't forget the database migration and CURRENT_SCHEMA_VERSION bump), and provide a facilities in the code for A) easily creating new malefactor bans and B) caching malefactor bans in memory to avoid a database dip every time a CORES package is received.

Don't write code yet to check for or respond to malefactor bans.

Dispatcher: HTTPS Masquerade Capability

Make the Dispatcher listen on port 443 for masquerade HTTPS traffic. When it receives masquerade HTTPS traffic, it should unmask it and send it to either the Hopper or the Neighborhood, as appropriate. When it is given Hopper or Neighborhood traffic to send, it should make a decision about how to send the traffic, and if that decision is for HTTPS masquerade traffic, the traffic should be masked as a believable HTTPS request (probably meaning PUT or POST) and sent to port 443.

Make sure the Dispatcher can tell the difference between incoming masquerade HTTPS traffic for the Hopper or the Neighborhood and incoming real HTTPS traffic for the Proxy Server or Proxy Client.

Note from Dan: The last paragraph here has been overtaken by events. If the request arrives on localhost:80, then it's from a browser or other client; if it arrives on 0.0.0.0:*, then it's from outside.

Customizable DNS Configuration

Overview

DNS is hard coded to port 53, which means if it conflicts with a locally running port, you have to stop the service, or build a docker image. I also dont want to use docker as it makes security management more difficult.

Customizable DNS Server / Port

For security schizos like myself who run local infrastructure like DNSCrypt with lots of caching, the concerns mentioned in https://github.com/MASQ-Project/Node/blob/master/node/docs/PORT_53.md can be completely avoided without needing to disable locally running DNS servers.

Therefore a good solution would be to allow delegation to a different dns server

Avoid bothering the routing engine if there's no consuming wallet

The handler for RouteQueryMessage (perhaps RouteQueryRequest by the time this card is played) in Neighborhood invokes the Routing Engine to create a route before checking to see if a consuming wallet has been supplied.

Since the only routes that don't require a consuming wallet are Gossip routes, and RouteQueryMessage is never used for Gossip routes (because they're too simple to require it), every route requested by a RouteQueryMessage always requires a consuming wallet, and requiring the presence of a consuming wallet right when the RouteQueryMessage is received would prevent a call to the Routing Engine in cases where the work of the Routing Engine is about to be discarded anyway.

Move the consuming-wallet check from Neighborhood::compose_route_query_response() to Neighborhood::route_query_message(). If there's no consuming wallet, return None directly (with an appropriate error log) instead of calling deeper.

Entry_DNS component toggle for Node

Currently when the MASQ starts, it always runs with entry_dns on and port 53 is listened to by Node.

Design a way to allow a startup parameter to be toggled that will turn off entry_dns and not require Node to listen on port 53, so other software can listen on the port unobstructed.

*Consider removing the entry_dns component, if system wide subversion is never to be a "thing"

Present a log to user to remind them that they will need to proxy network traffic/software to MASQ for privacy routing

ALSO check the daemon to ensure that entry_dns is not starting when daemon is running - there is a chance that this was turned on during some

Command for inspecting processes with MASQNode
macOS
ps -ef | grep MASQNode (includes this command)

window
netstat -ano

List processes listening on port 53:
macOS
lsof -Pn -i :53

Spike - Long `Drop` processing during panic?

We may at some point want to do some time-consuming processing during a panic--for example, if we're holding data in memory that will at some point be written to the database, but a panic occurs before the write is scheduled, we might want to do the writes to the database after the panic occurs but before the program actually halts.

We don't know at this point whether all three operating systems will allow us to run for several seconds during a panic: it seems reasonable that after telling a process to terminate, an OS would keep track of it and forcibly kill it if it didn't die after a short time.

Write a test (suggested project: masq_lib) that involves a struct for which the Drop trait is implemented. Have the Drop handler do something that takes ten or fifteen seconds--something other than just sleeping, since the OS is in charge of sleeping and may deceive us during a panic. Create an instance of the struct and panic; see if the Drop handler is permitted to take all the time it needs, or whether it's interrupted by the OS. (This test may be a little ticklish, since it involves a panic.)

We are pretty sure Linux will wait for at least fifteen seconds; we don't know about macOS or Windows.

The test doesn't need to become a permanent part of the codebase, since it will necessarily suck up lots of test runtime, but the results of the test should be appended to this card for posterity, so that we can come back and look at them after we forget what happens.

Free World Bit from GLD

Use the public IP, if available, to obtain the country code from the GLD database. Check the country code against a hard-coded list of non-Free-World countries to see whether we're in the Free World or not, and add that information to our Node Record in the Neighborhood.

[DUPLICATE] Design treatment for too long pending transactions

With the arrival of MASQ-Project/MASQ-Node-issues#523 we have a very simple mechanism that concerns monitoring pending transactions with regard to the how long is it taking for the transaction to come to completion. Some may stay pending even for a long time.

Now we only call all transactions older 6 hours bad transactions and we mark them with the failure mark - that means we just give all the responsibility over to the user's hands, because no other transaction for the same account can be send now and also the user has to decide what to do to solve the cause of the failure (moreover the hypothetically failed transaction can be later confirmed as successful because we don't really know if it's not going to succeed)

Suggestions:
We probably want to provide the standard functionality, that is, to automatically resent the transaction with higher gas price (increased by some percentage) when we've passed enough long time from the creation of the transaction.

There is another suggestion regarding the way how we should measure the passed time. The straightforward method is just counting with time units; the more sophisticated way is by the number of chain blocks added after the block from moment of sending the transaction.

The latter method requires us to be able to retrieve the current block number which may cause the need of another RPC-JSON call to the blockchain.

Be aware that these issues are linked to pending transactions being in air for a while, quick failures don't fall under these and so, of course, we won't want to retry the failed transaction at least not until we are able to determine the right cause of the failure.

GL/TLD: TLD-To-Country Service

Build a top-level-domain-to-country-code-group service into the SubstratumNode. This will probably be part data and part code. Make the Node capable of accepting a hostname in its RouteQueryMessage. Put a debug log in the Neighborhood that gives a list of acceptable exit-node countries whenever a route to a hostname is constructed.

Note: this probably shouldn't be an actor.

Startup DNS Check: Startup

Modify the startup code to use well-known public DNS servers and well-known websites to tell whether the Node is operating in the Free World or not. Print this information to the console as part of the startup message.

Reject Lies About Failed Nodes

When a reversal-mode CORES package arrives back at the Origin Node, instead of immediately banning the failed Node, first probe it with Ping to make sure it's really dead, and only ban it if it doesn't respond.

If it does respond, give the Node that reported it dead a suspicion point.

(We use banning rather than simple removal because we might in future get Gossip from another Node that does not yet recognize the failed Node as being down, and we don't want it back in our database. Whether it's down or corrupt, in either case its public key should be blacklisted.)

Users Shouldn't Be Required To Run Root

Overview

To make it easy for users, Masq provides a fairly straight forward dns implementation. It is however very detrimental to security, and as such there is a beter path.

Solution (Mid Tier)

Before startup grant MASQNode cap_net_bind_service permissions with:

$> sudo setcap 'cap_net_bind_service=+ep' /bin/masq-node

Solution (Chad Tier)

Because security schizos want to maximize security, i also dont want to grant potentially lethal workaround permissions to the masq node. Therefore a good solution would be to allow evry port to be customizable, as well as the option of using an external dns server.

Contact the authors of linefeed

There is nice chance, I think, that we could ask authors of linefeed library for some corrections that could reflect certain minor bugs we're gonna have to deal with otherwise. There is danger that people will blame us for we haven't fixed bugs in our code.

At this point, I think we have enough information to say that we're dealing with a ghost cursor on Windows, in the simplest cmd in particular. What does it do or when? From my observation, because the cursor is blinking while it's waiting for the input if you enter what you typed just at the moment when the cursor is shown on the screen it will persist there, or in other words that immediate state of him freezes in place although we've already gotten a new blinking cursor on a new line.

You can see more of such frozen cursors in the same time in the terminal, all depends on the timing in which you're executing your supplied strings.

If you scroll far away so that the incriminated place becomes covered behind the boarders of the terminal and when you get back then ghosts of those cursors are gone.


Secondly. This is just an assumption though. I think that handling of the signal Ctrl + c doesn't work. (Maybe of others too - now it's in the phase of testing) I haven't been in a situation where it would; still I think I miss nothing regarding how it's intended to get working in the code thought it isn't.

Dispatcher: HTTP Masquerade Capability

Make the Dispatcher listen on port 80 for masquerade HTTP traffic. When it receives masquerade HTTP traffic, it should unmask it and send it to either the Hopper or the Neighborhood, as appropriate. When it is given Hopper or Neighborhood traffic to send, it should make a decision about how to send the traffic, and if that decision is for HTTP masquerade traffic, the traffic should be masked as a believable HTTP request (probably meaning PUT or POST) and sent to port 80.

Make sure the Dispatcher can tell the difference between incoming masquerade HTTP traffic for the Hopper or the Neighborhood and incoming real HTTP traffic for the Proxy Server or Proxy Client.

Note from Dan: The last paragraph here has been overtaken by events. If the request arrives on localhost:80, then it's from a browser or other client; if it arrives on 0.0.0.0:*, then it's from outside.

Properly Default --dns-servers

--dns-servers should always be an optional parameter, and if it is not specified (but is still needed) it should default to the regular system DNS (for example, 192.168.0.1). Without specific direction, Node should not change the network signature of the machine running it.

[Bug] Hitting Consuming gives

SubstratumNode Version
Commit 69f4270

Describe the bug
When starting the Node , and hitting the Consume button, this error is shown:

To Reproduce

  1. Delete node.db
  2. Start Node
  3. Recover Wallet
  4. Start Node
  5. Enter a descriptor
  6. Hit Consume -> Error

** Additional info:
When I hit Serve, no error occurs and the Node can join the neighboorhood which is validated by the diagraph showing bidirectional connections. The Node in Red is the Win10 Node.

image

Screenshots
image

GL/TLD: Impostor Detection

Make the Hopper check incoming relay traffic to see if it comes from a Node that's lying about the country it resides in, and ignore the traffic if so. Also, malefactor-ban the source.

Get started with VACUUM

VACUUM is a SQLite-specific operation that squeezes deleted space out of database files. It's interesting for two reasons. First, it makes the files consume less disk space; second, it overwrites the deleted space so that it cannot be forensically analyzed by an attacker to recover some or all of the data that was deleted.

VACUUM is not an operation that should be performed whenever anything is deleted from the database: that would be too expensive. However, it should be performed on a reasonably frequent basis to protect the user's privacy and disk space.

Write some code to perform the VACUUM operation periodically, noting that it should not take place while the database is being used for anything else.

Suggestions: One good time to perform a VACUUM operation might be during a Graceful Shutdown (put card number in here). However, it will still be possible for the Node to crash unexpectedly, in which case the database file will be unVACUUMed. Therefore, it might be advisable to VACUUM during bootstrap as well.

Inaccessible List: Gossip

Modify the Neighborhood database and the Gossip protocol to handle the dissemination of the unreachable list. Add a set of debug logs to the Gossip acceptor to chronicle the acceptance of Gossip, including the unreachable lists.

GL/TLD: Route Query

Make the Neighborhood search for exit nodes in the acceptable countries whenever it constructs a route to a hostname, and choose the actual exit node from that list. (Choose simply and deterministically: always the first, or some globally incrementing integer modulo the list length, or whatever; no complications.)

Make scan timing and RatePack configurable

Reference MASQ-Project/MASQ-Node-issues#190

Rows need to be added to the CONFIG table, and provisions made in PersistentConfiguration, MASQNode-UIv2 and masq, and logic added in the code, to make configurable persistently and at runtime the following values:

Blockchain service URL (node_configurator_standard.rs)
payment_suggested_after_sec
payment_grace_before_ban_sec
permanent_debt_allowed_gwei
balance_to_decrease_from_gwei
balance_decreases_for_sec
unban_when_balance_below_gwei (accountant/mod.rs)
routing_byte_rate
routing_service_rate
exit_byte_rate
exit_service_rate (neighborhood.rs)
payable_scan_interval
receivable_scan_interval
pending_payment_scan_interval (accountant/mod.rs)

Historical note: the names in the code have the word "gwub" in place of the word "gwei" above; "gwub" was an attempt at a humorous combination of "gwei" (gigawei) and "SUB" (the original ERC-20 token used by Substratum). It was weak at best and is of no use now, so these names should be changed to something clearer.

Suggestion: the names of the values in the database (and preferably in the code as well) would be easier to understand if they included the unit of measurement at the end: for example, permanent_debt_allowed_gwei is much easier to understand than routing_byte_rate.

If the meanings of the values in accountant/mod.rs are not clear enough to complete this card, contact Dan for further information.

Note: As a part of this card, we've reseted default values for the three group of parameters by which we de facto eliminated MASQ-Project/MASQ-Node-issues#550. We did so with that effect in mind.

Deprecate Ropsten Testnet

This is continuing a removed card #609 in Node-Issues

Ropsten has long been deprecated.

Consider adding the current testnets for ETH if required (Sepolia)

Graceful Shutdown UI Messaging

'Graceful Shutdown'

When one UI shuts down a Node with the shutdown command:

  • All other UIs connected to the Node should spontaneously show a message indicating that the Node has shut down. One way to accomplish this would be to make the Node explicitly shut down all its UI connections before it dies, and have the UIs be sensitive to their connections being closed.

  • All other UIs connected to the Daemon should spontaneously show a message indicating that the Node has shut down. One way to accomplish this (may already be implemented) is to have the Daemon sense when its child process dies and send a broadcast to all connected UIs.

  • When a UI is connected to the Node and the Node shuts down, the UI reconnects to the Daemon. However, in no case should a Node-connected UI display the shutdown message caused by the Node disconnecting, then reconnect to the Daemon and also show the broadcast from the Daemon about the Node shutdown. This may be accomplished either by preventing the Daemon from sending the broadcast to UIs that connect after it senses the Node shutdown (preferable), or by making the UI ignore the Daemon's broadcast if it has already sensed the shutdown (may be quite a bit more difficult to get the sequencing right).

[Feature Request] Colorize terminal output

Please support color and bold styles to beautify terminal output. For example, make local node descriptor in Bold font, and colorize INFO, TRACE, DEBUG, ERROR, WARN into blue, green, dark green, red, orange, respectively.

Something like this
https://rust-lang-nursery.github.io/rust-cookbook/cli/ansi_terminal.html

Dan comment 4-Nov:
We probably don't want to bother colorizing the output to the logfiles, because we eventually want to make that output JSON or some other machine-readable format, and colorizing the output would just obfuscate that; but using ANSI color for CLI output is a good idea, and I can imagine a CLI command such as

masq show logs --log-level debug --format colorized-text

that would show logs in real time on the console in text form with ANSI color.

Add default node descriptors

If we want to achieve mass adoption of MASQ, we need to make it very user friendly with convention over configuration in mind.
Forcing the user to find a node descriptor and copy/paste it is a blocker.

Proposed solution is to run some official node descriptors, which will be by default pre-filled in MASQ client. Or alternative solution, is to implement some algorithm that will pre-fill the most suitable Node descriptor to maintain network health or stability or the one that will be fastest for the user.

Build one Masquerader

Build a TlsMasquerader that makes data look like one or more valid TLS ApplicationData packet(s),
and that can reassemble such packets on the other side of a Node-to-Node connection and extract the hidden CORES package.

Make sure that:
A) the TlsMasquerader puts a signature in the masked data so that, when presented with the data, it can tell whether or not it can handle unmasking of that data. (Talk to Dan about how to employ encryption here.) It's important that the TlsMasquerader not assume that it's the only Masquerader in the system.
B) space is left for other TLS Masqueraders as well. Real TLS connections don't consist solely of ApplicationData packets; therefore, as we become more clandestine, we'll have to enhance the existing TLS Masqueraders and add more.

GL/TLD: Automatic Updates

Make a Jenkins job and supporting automation to download a fresh copy of the IP-to-country-code database after every update (2nd of each month for IP2LOCATION), convert it, and apply it to the next SubstratumNode build automatically.

Shutdown command does not work as we thought

The supposed response on UiShutdownRequest, where UiShutdownResponse comes in mind, is never being sent actually. We miss this code in this request's handle in Neighborhood. It only exits the process of the Node which is quite brutal. At any rate, UishutdownResponse doesn't figure in the production code.

We will want to go even further with time going (to some last-bye communication with other Nodes before disconnecting) but for now we want to rectify that we don't send a full-valued response message to our UIs. They deserve more :)

Send a UiShutdownResponse from the same handle back to UiGateway. For that you may need to integrate subscribers of NodeToUiMessages in Neighborhood and this also requires a mortification of the BindMessage and of its handle. The following is just a temporal bridge but we also want to make sure that the response make it over to the UiGataway where it must be dispatched over the websocket connection, all in time, before the whole process terminates. So we probably want to sleep a while before we actually call exit_process().

Neighborhood Route Extension

A Neighborhood with only short routes, asked for a long route, should send requests to the nodes at the leaves of its routing tree in an attempt to extend the tree so that it can answer the original request. If a route of sufficient length is found, it is returned immediately, even if other results are still coming in; the other results are fielded and added to the database as well, as they arrive.

Terminal Intelligence with Free World Bit

When seeking an exit Node for a data route, categorize the target hostname as Free-World or non-Free-World. If non-Free-World, defer to the next method of Terminal Intelligence.

If the target is Free World, select a Free World exit Node from the Neighborhood database.

Note: Use the TLD database to get a country code for the hostname, then the non-Free-World country list to get a Free World bit for the target.

Retaining Unwritten Debts in Memory

When the Node crashes when it has a bunch of unwritten debts in memory, and they disappear without making it into the database.

We build the Node not to crash, so theoretically crashing shouldn't be that big a concern; but remember, before we play the Graceful Shutdown epic, every Node shutdown is indistinguishable from a crash, because it just stops the process dead. Therefore, presently there's no way to move a Node from the running state to the not-running state without crashing it.

This concern might raise the priority of Graceful Shutdown...

Bert โ€” 09/06/2022
I've invented a concept how we can escape from this threat. There is even a card about it and I keep it back in my head hoping it will be implemented. It would solve a trouble in your named case but also in some other. So it has a potential of a general purpose help structure. Solved by combining an impl of Drop with writing important data to database in the program's post-morte moments. When overally crashing, we still can save the data persistently. We just need a smart wrapper. I've also proved the concept in a spike, if you have doubts.
Dan Wiebe โ€” 09/06/2022
Drop implementations won't work for what we have now. When you kill a process the way we kill it, the operating system simply doesn't schedule its next timeslice. It's removed from the process queue and thrown away without ever getting another chance to run.

Graceful Shutdown is of course the ultimate solution to this problem. An interim solution (at least for Linux and Mac) would be, instead of terminating the process, to send it a SIGTERM signal. We'd have to sense that signal and make sure all the various threads and actors were made properly aware of it. As a matter of fact, that exact functionality will probably be part of Graceful Shutdown.

Graceful Shutdown Spike

Currently, when a Node is ordered to shut down, it simply kills its own process. No file handles or TCP/database/WebSockets connections are closed, nothing is gently deallocated, nothing is cleaned up in the database, and no Gossip is sent.

Node shutdown should be much more graceful than this. Pending operations should be completed, handles and connections should be closed, neighbors should be notified, and so on.

Create a set of cards detailing all the various operations that need to be performed in the process of a Graceful Shutdown. Note that #404 and #407 already exist.

Also to be included is #410

One of the things to be considered is the logger: what if the Node wants to shut down just as the logger is rotating the logfiles in a background thread? The logger library provides hooks for this, but the hooks will need to be used.

Quiet and Shy

Suppose Gossip shows up at a clandestine port from a Node we don't already know. This Node could be an attacker trying to A) identify us as a MASQ Node, and B) put our IP address on a government watch list.

Adding this Node to our Neighborhood and sending it CORES packages will absolutely confirm our identity as a MASQ Node, so we don't necessarily want to do that.

Even accepting a connection on a clandestine port, even if we immediately close it, will confirm at least that we have that clandestine port open and may be a Substratum Node. We'd rather not do that either.

Solution: rework the clandestine listeners at a lower level, so that whenever a TCP SYN is received, the Neighborhood is consulted to see if the Node attempting to connect is known by IP address. If so, continue the connection handshake with a SYN-ACK and proceed normally.

If not, ignore the TCP SYN altogether, so that it will look like the clandestine port is not open.

Note: this may require handling 127.0.0.1:80 and 127.0.0.1:443 (loopback ports for the local browser) differently from NIC:80 and NIC:443 (external clandestine ports for CORES traffic).

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.