evilsocket / opensnitch

OpenSnitch is a GNU/Linux interactive application firewall inspired by Little Snitch.
GNU General Public License v3.0
10.74k stars 498 forks source link

Cannot compile daemon #160

Closed wiserweb closed 6 years ago

wiserweb commented 6 years ago

Looks like Makefile wants to run certain commands but fails on glide.

Using latest source.

deps: 
    @glide up
make
make: dep: Command not found
Makefile:10: recipe for target 'deps' failed
make: *** [deps] Error 127
 glide up
[ERROR] Failed to find glide.yaml file in directory tree: Cannot resolve parent of /
/opensnitch/opensnitch/daemon $ go build .
# _/home/user/Applications/opensnitch/opensnitch/daemon
./main.go:43: undefined: netfilter.Queue
./main.go:44: undefined: netfilter.Packet
./main.go:45: undefined: netfilter.Packet
./main.go:107: undefined: netfilter.Packet
./main.go:117: undefined: firewall.DropMarked
./main.go:119: undefined: procmon.Stop
./main.go:139: undefined: netfilter.Packet
./main.go:231: undefined: procmon.Start
./main.go:252: undefined: netfilter.NewQueue
./main.go:263: undefined: firewall.DropMarked
./main.go:263: too many errors
evilsocket commented 6 years ago

nope, you're not using the latest version ... https://github.com/evilsocket/opensnitch/blob/master/daemon/Makefile#L9

wiserweb commented 6 years ago

Sorry @evilsocket I am using the latest. I made a mistake when creating the issue. I had an older version in ~/Download that I took Make file contents from instead of latest clone.

Running Ubuntu 16.04/Mint18

git clone git@github.com:evilsocket/opensnitch.git

Following readme

go get -u github.com/golang/dep/cmd/dep
package context: unrecognized import path "context" (import path does not begin with hostname)

I suppose this must be related to compile issues.

wiserweb commented 6 years ago

"This is not related to opensnitch, make sure you're using a recent Go version and that you installed it correctly"

This is related to GO.

Ubuntu 16.04 repo provides Go package v1.6 but v1.8 or greater is required to make this work.

The solution is to get the latest from https://golang.org/dl/ and try the Readme steps again.

I think many folks new to Go might stumble on his step.

Here are the steps to update Go on your system.

Remove existing version of Go. sudo apt-get purge golang*

Remove directories that contained old go version which can cause 'unrecognized import path "context"' issues. sudo rm -rf /usr/lib/go /usr/lib/go/src

Install latest Go version for your 64bit system.

curl -O https://dl.google.com/go/go1.10.1.linux-amd64.tar.gz

tar -xvf go1.10.1.linux-amd64.tar.gz

go sudo mv go /usr/local

Update your paths

Check Go version go version

evilsocket commented 6 years ago

Again, from the README:

Make sure you have a correctly configured Go >= 1.8 environment,

"I think many folks new to Go might stumble on his step." only the ones who don't RTFM.

wiserweb commented 6 years ago

I read the MFM....

Opensnitch is probably only Go app on my system at the moment so there is a learning curve.

wiserweb commented 6 years ago

And so grateful that you wrote Opensnitch..... I want to make sure any Joe 6-pack can run this so that we can onboard more devs to Linux away from MacOS...

wiserweb commented 6 years ago

You're obviously more advanced with Go than the average person out there.... keep in mind... If it was so clear and obvious there wouldn't be any tickets for this.... but there are... multiple...

It's does not diminish the value of the project to include more in depth instructions in the Readme.

See NVM project with 26K stars which includes little notes for caveats that people might run into... this helps guide people along for most common edge cases.

https://github.com/creationix/nvm

evilsocket commented 6 years ago

I would totally agree with you if it wasn't for one reason: this software did not reach 1.0.0 stable yet, that is why I'm not putting such detailed instructions, I'm trying to only filter for the developers that can help me now. More detailed instructions (and precompiled binaries) will be made available once 1.0.0 is ready and open to everyone to use.

wiserweb commented 6 years ago

Ok... understood.. I'll be available to help with the more detailed instructions.

I'm still running into issues even with latest Go... any idea what could be the cause?

$ go version
go version go1.10.1 linux/amd64
go get github.com/golang/protobuf/protoc-gen-go
owner@owner ~/Applications/opensnitch $ go get -u github.com/golang/dep/cmd/dep
owner@owner ~/Applications/opensnitch $ go get github.com/evilsocket/opensnitch
can't load package: package github.com/evilsocket/opensnitch: no Go files in /home/owner/go/src/github.com/evilsocket/opensnitch
owner@owner ~/Applications/opensnitch $ cd $GOPATH/src/github.com/evilsocket/opensnitch
owner@owner ~/go/src/github.com/evilsocket/opensnitch $ make
make[1]: Entering directory '/home/owner/go/src/github.com/evilsocket/opensnitch/proto'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/home/owner/go/src/github.com/evilsocket/opensnitch/proto'
owner@owner ~/go/src/github.com/evilsocket/opensnitch $ sudo make install
[sudo] password for owner: 
make: *** No rule to make target 'install'.  Stop.
wiserweb commented 6 years ago

Hi @evilsocket, testers and developers might find these steps helpful.

Complete steps for new systems

These are tested against Ubuntu 16.04 / Mint 18.

IMPORTANT: You must delete any prior version of opensnitch as the make/install is being perfected for v1.0. Go get is not smart like git, you must manually delete old repository before fetching new one. You have been warned.

# delete old src for opensnitch if applicable
rm -r ~/go/src/github.com/evilsocket

# install system dependencies
sudo apt-get -y install python3-pip python3-setuptools protobuf-compiler libpcap-dev libnetfilter-queue-dev python-pyqt5 curl

# remove old Go <1.8 
sudo apt-get purge golang*
sudo rm -rf /usr/lib/go /usr/lib/go/src

# install latest Go 1.10 
curl -O https://dl.google.com/go/go1.10.1.linux-amd64.tar.gz
tar -xvf go1.10.1.linux-amd64.tar.gz
go sudo mv go /usr/local

# Note, setting up Go PATH is outside the scope of this guide, these are just tips.
# update your Go path, some use .profile to set their PATHS, this depends on your system
# modify the appropriate file for your system
nano ~/.bashrc
export GOROOT="/usr/local/go"

# if updating Go to newer version simply modify your GOROOT path to match the path above

# update essential python packages to latest for compilation
sudo pip3 install --upgrade pip
sudo pip3 install --upgrade setuptools

# install go dependencies for opensnitch
go get github.com/golang/protobuf/protoc-gen-go
go get -u github.com/golang/dep/cmd/dep

# clone the repository (ignore the message about no Go files being found)
go get github.com/evilsocket/opensnitch
cd $GOPATH/src/github.com/evilsocket/opensnitch

# build UI and install
cd ui
sudo pip3 install -r requirements.txt
sudo pip3 install .

# build daemon and install service
cd ..
cd daemon
make
sudo make install

# enable opensnitch as a systemd service and start the UI
sudo systemctl enable opensnitchd
sudo service opensnitchd start
opensnitch-ui
b3taman commented 6 years ago

For a new golang install, add the following at the appropriate place wherever you set your paths:

export GOPATH="{full path to $HOME}/gocode"
export PATH="$PATH:$GOPATH/bin"

This saves a lot of time if OpenSnitch is the only reason you have golang installed.

jwingnut commented 6 years ago

Thanks, this thread was helpful in installing OpenSnitch. It'd be great to consider using this as the install instructions.

tinyhazeleyes commented 6 years ago

On Mint I had to install python3-dev.

Thank you for sharing :)

flerpadoo commented 5 years ago

All I needed to do was add $GOPATH/bin to $PATH and then the make ran successfully