Sfoglia il codice sorgente

Added Vagrantfile for test and development purposes.

Christian Sieber 7 anni fa
parent
commit
c517102029
5 ha cambiato i file con 52 aggiunte e 3 eliminazioni
  1. 1 0
      .gitignore
  2. 25 0
      README.md
  3. 22 0
      Vagrantfile
  4. 3 2
      main.py
  5. 1 1
      templates/main.html

+ 1 - 0
.gitignore

@@ -0,0 +1 @@
+.vagrant/

+ 25 - 0
README.md

@@ -28,3 +28,28 @@ No further changes are planned right now, but pull requests are welcome.
     ```
 
 - The tool will read your interfaces and the current setup every time the site is reloaded
+
+## Test & Develop
+
+You can use the supplied Vagrantfile to test tcgui quickly. Vagrant will setup two machines, sender (192.168.210.2) and a receiver (192.168.210.3):
+
+	vagrant up
+
+Afterwards connect to the sender and start the GUI:
+
+	vagrant ssh sender
+	cd /vagrant
+	sudo python3 main.py --ip 0.0.0.0 --debug
+
+Start a receiver in the receiving VM:
+
+	vagrant ssh receiver
+	iperf3 -s
+	
+Send a packet stream from the sender to the receiver:
+
+	vagrant ssh sender
+	iperf3 -c 192.168.210.3 -t 300
+
+Now access the GUI at http://192.168.210.2:5000/ and change the rate of interface eth1. You should see the sending/receiving rate to decrease to the set amount.
+

+ 22 - 0
Vagrantfile

@@ -0,0 +1,22 @@
+# -*- mode: ruby -*-
+# vi: set ft=ruby :
+
+Vagrant.configure("2") do |config|
+  config.vm.box = "debian/jessie64"
+
+  config.vm.define "sender" do |cfg|
+  	config.vm.provision "shell", inline: <<-SHELL
+            apt-get update
+            apt-get install -y iproute python3 python3-flask iperf3
+	SHELL
+	cfg.vm.network "private_network", ip: "192.168.210.2"
+  end
+
+  config.vm.define "receiver" do |cfg|
+  	config.vm.provision "shell", inline: <<-SHELL
+            apt-get update
+            apt-get install -y iperf3
+	SHELL
+	cfg.vm.network "private_network", ip: "192.168.210.3"
+  end
+end

+ 3 - 2
main.py

@@ -145,8 +145,9 @@ def parse_rule(split_rule):
 
 
 if __name__ == "__main__":
-    #if os.geteuid() != 0:
-    #    exit("You need to have root privileges to run this script.\nPlease try again, this time using 'sudo'. Exiting.")
+    if os.geteuid() != 0:
+        print("You need to have root privileges to run this script.\nPlease try again, this time using 'sudo'. Exiting.")
+        exit(1)
     args = parse_arguments()
     if args.regex:
         pattern = re.compile(args.regex)

+ 1 - 1
templates/main.html

@@ -2,7 +2,7 @@
 <html lang="en">
 <head>
     <meta charset="UTF-8">
-    <title>DemoSetup</title>
+    <title>tcgui</title>
 </head>
 <body>
 <h4>Available Interfaces</h4>