VPN-Management-GUI 2.0.3 porting start
This commit is contained in:
3
Admin/Modules/Squid/squid_dynamic/README
Normal file
3
Admin/Modules/Squid/squid_dynamic/README
Normal file
@@ -0,0 +1,3 @@
|
||||
export CPATH=..:$HOME/include:/usr/local/include:/usr/include:/usr/include/mysql
|
||||
needed: libmysqlclient-dev
|
||||
gcc -l mysqlclient -o traffic Traffic.c
|
4
Admin/Modules/Squid/squid_dynamic/db.conf
Executable file
4
Admin/Modules/Squid/squid_dynamic/db.conf
Executable file
@@ -0,0 +1,4 @@
|
||||
user: openvpn
|
||||
passwd: openvpnlog
|
||||
database: openvpn
|
||||
host: localhost
|
7
Admin/Modules/Squid/squid_dynamic/hexer
Executable file
7
Admin/Modules/Squid/squid_dynamic/hexer
Executable file
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
let x=0x3f
|
||||
echo $x
|
||||
|
||||
|
||||
let x=0xfffe
|
||||
echo $x
|
134
Admin/Modules/Squid/squid_dynamic/squid_dyn.c
Normal file
134
Admin/Modules/Squid/squid_dynamic/squid_dyn.c
Normal file
@@ -0,0 +1,134 @@
|
||||
/* OpenVPN - Squid Load Balancer*
|
||||
*------------------------------*
|
||||
* Version 1.0 *
|
||||
* Written by Christoph Haas *
|
||||
* License: LGPL *
|
||||
* 12.10.2010 *
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <mysql/mysql.h>
|
||||
#include <regex.h>
|
||||
#include <string.h>
|
||||
|
||||
#define __MAX_LINE__ 100
|
||||
#define __MAX_FIELD__ 255
|
||||
#define false 0
|
||||
#define true 1
|
||||
|
||||
|
||||
MYSQL mysql;
|
||||
|
||||
int connect_db(char *config)
|
||||
{
|
||||
FILE *db_data = NULL;
|
||||
regex_t reg;
|
||||
char user[__MAX_LINE__] = "";
|
||||
char passwd[__MAX_LINE__] = "";
|
||||
char database[__MAX_LINE__] = "";
|
||||
char host[__MAX_LINE__] = "";
|
||||
int port = 0;
|
||||
char tmp[__MAX_LINE__];
|
||||
char buf[__MAX_LINE__];
|
||||
int a, b;
|
||||
int length;
|
||||
|
||||
if((db_data = fopen(config, "r")) == NULL)
|
||||
{
|
||||
fprintf(stderr, "Can't open %s for reading.\n", config);
|
||||
return false;
|
||||
}
|
||||
regcomp(®, "^([a-zA-Z0-9:]+)[ ][a-zA-Z0-9]+$", REG_EXTENDED | REG_NEWLINE);
|
||||
while(fgets(buf, __MAX_LINE__, db_data))
|
||||
{
|
||||
length = strlen(buf);
|
||||
if(length < 3)continue;
|
||||
if(length >= __MAX_LINE__)
|
||||
{
|
||||
fclose(db_data);
|
||||
regfree(®);
|
||||
fprintf(stderr, "To long line in config file.\n");
|
||||
return false;
|
||||
}
|
||||
if(buf[0] == '#')continue;
|
||||
if(regexec(®, buf, 0, 0, 0))
|
||||
{
|
||||
fclose(db_data);
|
||||
regfree(®);
|
||||
fprintf(stderr, "Syntax error in config file.\n");
|
||||
return false;
|
||||
}
|
||||
for(a = 0, b = 0; a < strlen(buf); a++)
|
||||
{
|
||||
if(buf[a] == ' ')b++;
|
||||
}
|
||||
if(b != 1)
|
||||
{
|
||||
fclose(db_data);
|
||||
regfree(®);
|
||||
fprintf(stderr, "Syntax error in config file.\n");
|
||||
return false;
|
||||
}
|
||||
if((strncmp(buf, "user: ", 6)) == 0)sscanf(buf, "%s %s", tmp, user);
|
||||
if((strncmp(buf, "passwd: ", 8)) == 0)sscanf(buf, "%s %s", tmp, passwd);
|
||||
if((strncmp(buf, "database: ", 10)) == 0)sscanf(buf, "%s %s", tmp, database);
|
||||
if((strncmp(buf, "host: ", 6)) == 0)sscanf(buf, "%s %s", tmp, host);
|
||||
if((strncmp(buf, "port: ", 6)) == 0)sscanf(buf, "%s %d", tmp, &port);
|
||||
}
|
||||
fclose(db_data);
|
||||
regfree(®);
|
||||
if((strlen(user) < 1) || (strlen(passwd) < 1) ||
|
||||
(strlen(database) < 1) || (strlen(host) < 1))
|
||||
{
|
||||
fprintf(stderr, "One value for MySQL connection isn't set. \
|
||||
Please set user, passwd, database and host.\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
mysql_init(&mysql);
|
||||
if((mysql_real_connect(&mysql, host, user, passwd, database, port, NULL, 0)) == NULL)
|
||||
{
|
||||
fprintf(stderr, "%s\n", mysql_error(&mysql));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
char Query[200]= "SELECT * FROM userdata WHERE VPNId = '\0";
|
||||
|
||||
if(argc == 2)
|
||||
{
|
||||
/*iID = atoi(argv[1]);
|
||||
printf("Int:%d\n", iID);
|
||||
sprintf(ID,"%-#10x",iID);
|
||||
printf("String:%s\n", ID);*/
|
||||
|
||||
connect_db("/home/christoph/squid_dynamic/db.conf"); // Datenbank Verbindung aufbauen
|
||||
|
||||
strcat(Query, argv[1]); // Query builden
|
||||
strcat(Query,"'"); //
|
||||
|
||||
mysql_query(&mysql, Query); // Query abschicken
|
||||
result = mysql_store_result(&mysql); // Result speichern
|
||||
|
||||
while ((row = mysql_fetch_row(result))) // Alle Datensätze auslesen (in dem Fall eh nur einer)
|
||||
{
|
||||
printf("%s:%s\n", row[9], row[10]); // Feld 9 und 10 (login/pass) aus dem datensatz ausgeben
|
||||
}
|
||||
|
||||
mysql_free_result(result); // Result wieder löschen
|
||||
mysql_close(&mysql); // Datenbank Verbindung schliesen
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("USAGE: sqidy xx | xx = VPNId\n"); // bei flascheingabe der Parameter
|
||||
}
|
||||
}
|
BIN
Admin/Modules/Squid/squid_dynamic/squidy
Executable file
BIN
Admin/Modules/Squid/squid_dynamic/squidy
Executable file
Binary file not shown.
BIN
Admin/Modules/Squid/squid_dynamic/squidy.bak
Executable file
BIN
Admin/Modules/Squid/squid_dynamic/squidy.bak
Executable file
Binary file not shown.
1
Admin/Modules/Squid/squid_dynamic/vpnid
Normal file
1
Admin/Modules/Squid/squid_dynamic/vpnid
Normal file
@@ -0,0 +1 @@
|
||||
00
|
115
Admin/Modules/Squid/squid_dynamic/write_conf
Executable file
115
Admin/Modules/Squid/squid_dynamic/write_conf
Executable file
@@ -0,0 +1,115 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Zaehlvariable einlesen
|
||||
id=$ID_VPN
|
||||
|
||||
# Abfrage ob Stringlaenge von id NULL ist
|
||||
if [ ${#ID_VPN} == 0 ];
|
||||
then id=0
|
||||
fi
|
||||
|
||||
# id inkrementieren
|
||||
let id=$id+1
|
||||
|
||||
# 255 Overflow verhindern
|
||||
if [ $id -gt 254 ]
|
||||
then id=0
|
||||
fi
|
||||
|
||||
# Variable id fuer naechsten Durchlauf speichern
|
||||
export ID_VPN=$id
|
||||
|
||||
# id HEX wandeln
|
||||
hex=$(echo "obase=16; $id" |bc)
|
||||
|
||||
# Abfrage ob Strinlaenge von hex kleiner als 2
|
||||
if [ ${#hex} -lt 2 ];
|
||||
then hex=0$hex
|
||||
fi
|
||||
|
||||
# Login-Daten aus Datenbank holen
|
||||
credentials=$(./squidy $hex)
|
||||
# Abfrage ob Datensatz leer :
|
||||
zero="0"
|
||||
|
||||
if [ "$credentials" == ":" ];
|
||||
then
|
||||
. write_conf &
|
||||
zero="1"
|
||||
fi
|
||||
if [ ${#credentials} == 0 ];
|
||||
then
|
||||
. write_conf &
|
||||
zero="1"
|
||||
fi
|
||||
|
||||
######################################################################################
|
||||
|
||||
# Config- Datei schreiben.
|
||||
if [ $zero == "0" ]
|
||||
then
|
||||
echo "
|
||||
# Squid config by h44z
|
||||
|
||||
# TAG: http_port
|
||||
# Usage: port
|
||||
# hostname:port
|
||||
# 1.2.3.4:port
|
||||
http_port 10.8.0.1:3128 transparent
|
||||
http_port 10.8.0.1:8080
|
||||
#https_port 10.8.0.1:8181 key=/etc/apache2/ssl/apache.pem
|
||||
|
||||
|
||||
visible_hostname vpnrack
|
||||
|
||||
# TAG: icp_port
|
||||
icp_port 0
|
||||
|
||||
# TAG: no_cache
|
||||
acl QUERY urlpath_regex cgi-bin \\?
|
||||
no_cache deny QUERY
|
||||
|
||||
# TAG: cache_mem (bytes)
|
||||
cache_mem 32 MB
|
||||
|
||||
# TAG: cache_dir
|
||||
cache_dir ufs /var/cache/squid 100 16 256
|
||||
|
||||
# TAG: cache_access_log
|
||||
cache_access_log /var/log/squid/access.log
|
||||
|
||||
# TAG: cache_log
|
||||
cache_log /var/log/squid/cache.log
|
||||
|
||||
# TAG: cache_store_log
|
||||
cache_store_log /var/log/squid/store.log
|
||||
|
||||
# TAG: emulate_httpd_log on|off
|
||||
emulate_httpd_log on
|
||||
|
||||
# TAG: pid_filename
|
||||
pid_filename /var/run/squid.pid
|
||||
|
||||
# TAG: cache_mgr
|
||||
cache_mgr christoph.haas2@students.htlinn.ac.at
|
||||
|
||||
|
||||
http_access allow all
|
||||
acl https port 443
|
||||
http_access allow https
|
||||
|
||||
|
||||
# TAG: http_reply_access
|
||||
# Allow replies to client requests. This is complementary to http_access.
|
||||
#http_reply_access allow all
|
||||
|
||||
cache_peer 192.168.195.101 parent 8080 7 no-query default no-digest login=$credentials
|
||||
|
||||
never_direct allow all
|
||||
" > /etc/squid3/squid.conf
|
||||
|
||||
######################################################################################
|
||||
#restart squid
|
||||
killall -9 squid
|
||||
squid -D -YC -f /etc/squid3/squid.conf
|
||||
fi
|
132
Admin/Modules/Squid/squid_dynamic/write_conf_file
Executable file
132
Admin/Modules/Squid/squid_dynamic/write_conf_file
Executable file
@@ -0,0 +1,132 @@
|
||||
#!/bin/bash
|
||||
# Script um die cache_peer funktion von Squid upzudaten.
|
||||
# V1.0
|
||||
# 13.10.2010
|
||||
# Stoeckholzer, Haas
|
||||
|
||||
if [ ${#1} == 0 ];
|
||||
then
|
||||
echo "USAGE: write_conf_file updatetime"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
while [ "1" == "1" ] ;
|
||||
do
|
||||
sleep $1
|
||||
zero="1"
|
||||
|
||||
while [ $zero == "1" ] ;
|
||||
do
|
||||
|
||||
# Zaehlvariable einlesen
|
||||
id=$(cat /var/vpn/vpnid)
|
||||
|
||||
# id inkrementieren
|
||||
let id=$id+1
|
||||
|
||||
# 255 Overflow verhindern
|
||||
if [ $id -gt 254 ]
|
||||
then
|
||||
id=0
|
||||
fi
|
||||
|
||||
# Variable id fuer naechsten Durchlauf speichern
|
||||
echo $id > /var/vpn/vpnid
|
||||
|
||||
# id HEX wandeln
|
||||
hex=$(echo "obase=16; $id" |bc)
|
||||
|
||||
|
||||
# Abfrage ob Strinlaenge von hex kleiner als 2
|
||||
if [ ${#hex} -lt 2 ];
|
||||
then
|
||||
hex=0$hex
|
||||
fi
|
||||
|
||||
black=$(cat /var/vpn/blacklist | grep $hex)
|
||||
|
||||
if [ ${#black} -lt 2 ];
|
||||
then
|
||||
# Login-Daten aus Datenbank holen
|
||||
credentials=$(/home/christoph/squid_dynamic/squidy $hex)
|
||||
# Abfrage ob Datensatz leer :
|
||||
|
||||
if [ ${#credentials} -gt 10 ];
|
||||
then
|
||||
zero="0"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
echo "USING credentials: $credentials"
|
||||
|
||||
sudo killall -9 unlinkd
|
||||
sudo killall -9 squid
|
||||
|
||||
sudo rm /etc/squid3/squid.conf
|
||||
######################################################################################
|
||||
|
||||
# Config- Datei schreiben.
|
||||
sudo echo -e -n "
|
||||
# Squid config by h44z
|
||||
|
||||
# TAG: http_port
|
||||
# Usage: port
|
||||
# hostname:port
|
||||
# 1.2.3.4:port
|
||||
http_port 10.8.0.1:3128 transparent
|
||||
http_port 10.8.0.1:8080
|
||||
#https_port 10.8.0.1:8181 key=/etc/apache2/ssl/apache.pem
|
||||
|
||||
|
||||
visible_hostname vpnrack
|
||||
|
||||
# TAG: icp_port
|
||||
icp_port 0
|
||||
|
||||
# TAG: no_cache
|
||||
acl QUERY urlpath_regex cgi-bin \\?
|
||||
no_cache deny QUERY
|
||||
|
||||
# TAG: cache_mem (bytes)
|
||||
cache_mem 32 MB
|
||||
|
||||
# TAG: cache_dir
|
||||
cache_dir ufs /var/cache/squid 100 16 256
|
||||
|
||||
# TAG: cache_access_log
|
||||
cache_access_log /var/log/squid/access.log
|
||||
|
||||
# TAG: cache_log
|
||||
cache_log /var/log/squid/cache.log
|
||||
|
||||
# TAG: cache_store_log
|
||||
cache_store_log /var/log/squid/store.log
|
||||
|
||||
# TAG: emulate_httpd_log on|off
|
||||
emulate_httpd_log on
|
||||
|
||||
# TAG: pid_filename
|
||||
pid_filename /var/run/squid.pid
|
||||
|
||||
# TAG: cache_mgr
|
||||
cache_mgr christoph.haas2@students.htlinn.ac.at
|
||||
#blubber
|
||||
|
||||
http_access allow all
|
||||
acl https port 443
|
||||
http_access allow https
|
||||
|
||||
|
||||
# TAG: http_reply_access
|
||||
# Allow replies to client requests. This is complementary to http_access.
|
||||
#http_reply_access allow all
|
||||
|
||||
cache_peer 192.168.195.101 parent 8080 7 no-query default no-digest login=$credentials
|
||||
|
||||
never_direct allow all
|
||||
" > /etc/squid3/squid.conf
|
||||
echo "Written credentials: $credentials"
|
||||
######################################################################################
|
||||
#restart squid
|
||||
sudo squid -D -YC -f /etc/squid3/squid.conf
|
||||
done
|
130
Admin/Modules/Squid/squid_dynamic/write_conf_file.bak
Executable file
130
Admin/Modules/Squid/squid_dynamic/write_conf_file.bak
Executable file
@@ -0,0 +1,130 @@
|
||||
#!/bin/bash
|
||||
# Script um die cache_peer funktion von Squid upzudaten.
|
||||
# V1.0
|
||||
# 13.10.2010
|
||||
# Stoeckholzer, Haas
|
||||
|
||||
if [ ${#1} == 0 ];
|
||||
then
|
||||
echo "USAGE: write_conf_file updatetime"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
while [ "1" == "1" ] ; do
|
||||
|
||||
sleep $1
|
||||
zero="1"
|
||||
|
||||
while [ $zero == "1" ] ; do
|
||||
|
||||
# Zaehlvariable einlesen
|
||||
id=$(cat /var/vpn/vpnid)
|
||||
|
||||
# id inkrementieren
|
||||
let id=$id+1
|
||||
|
||||
# 255 Overflow verhindern
|
||||
if [ $id -gt 254 ]
|
||||
then id=0
|
||||
fi
|
||||
|
||||
# Variable id fuer naechsten Durchlauf speichern
|
||||
echo $id > /var/vpn/vpnid
|
||||
|
||||
# id HEX wandeln
|
||||
hex=$(echo "obase=16; $id" |bc)
|
||||
|
||||
# Abfrage ob Strinlaenge von hex kleiner als 2
|
||||
if [ ${#hex} -lt 2 ];
|
||||
then hex=0$hex
|
||||
fi
|
||||
|
||||
# Login-Daten aus Datenbank holen
|
||||
credentials=$(/home/christoph/squid_dynamic/squidy $hex)
|
||||
# Abfrage ob Datensatz leer :
|
||||
|
||||
if [ ${#credentials} -gt 10 ];
|
||||
then
|
||||
zero="0"
|
||||
fi
|
||||
echo "Schleife zero: $zero"
|
||||
echo "Schleife id: $id"
|
||||
echo "Schleife hex: $hex"
|
||||
done
|
||||
echo "USING zero: $zero"
|
||||
echo "USING id: $id"
|
||||
echo "USING hex: $hex"
|
||||
echo "USING credentials: $credentials"
|
||||
|
||||
sudo killall -9 unlinkd
|
||||
sudo killall -9 squid
|
||||
|
||||
sudo rm /etc/squid3/squid.conf
|
||||
######################################################################################
|
||||
|
||||
# Config- Datei schreiben.
|
||||
sudo echo -e -n "
|
||||
# Squid config by h44z
|
||||
|
||||
# TAG: http_port
|
||||
# Usage: port
|
||||
# hostname:port
|
||||
# 1.2.3.4:port
|
||||
http_port 10.8.0.1:3128 transparent
|
||||
http_port 10.8.0.1:8080
|
||||
#https_port 10.8.0.1:8181 key=/etc/apache2/ssl/apache.pem
|
||||
|
||||
|
||||
visible_hostname vpnrack
|
||||
|
||||
# TAG: icp_port
|
||||
icp_port 0
|
||||
|
||||
# TAG: no_cache
|
||||
acl QUERY urlpath_regex cgi-bin \\?
|
||||
no_cache deny QUERY
|
||||
|
||||
# TAG: cache_mem (bytes)
|
||||
cache_mem 32 MB
|
||||
|
||||
# TAG: cache_dir
|
||||
cache_dir ufs /var/cache/squid 100 16 256
|
||||
|
||||
# TAG: cache_access_log
|
||||
cache_access_log /var/log/squid/access.log
|
||||
|
||||
# TAG: cache_log
|
||||
cache_log /var/log/squid/cache.log
|
||||
|
||||
# TAG: cache_store_log
|
||||
cache_store_log /var/log/squid/store.log
|
||||
|
||||
# TAG: emulate_httpd_log on|off
|
||||
emulate_httpd_log on
|
||||
|
||||
# TAG: pid_filename
|
||||
pid_filename /var/run/squid.pid
|
||||
|
||||
# TAG: cache_mgr
|
||||
cache_mgr christoph.haas2@students.htlinn.ac.at
|
||||
#blubber
|
||||
|
||||
http_access allow all
|
||||
acl https port 443
|
||||
http_access allow https
|
||||
|
||||
|
||||
# TAG: http_reply_access
|
||||
# Allow replies to client requests. This is complementary to http_access.
|
||||
#http_reply_access allow all
|
||||
|
||||
cache_peer 192.168.195.101 parent 8080 7 no-query default no-digest login=$credentials
|
||||
|
||||
never_direct allow all
|
||||
" > /etc/squid3/squid.conf
|
||||
echo "Written credentials: $credentials"
|
||||
######################################################################################
|
||||
#restart squid
|
||||
sudo squid -D -YC -f /etc/squid3/squid.conf
|
||||
|
||||
done
|
183
Admin/Modules/Squid/squid_dynamic/write_conf_manuell
Executable file
183
Admin/Modules/Squid/squid_dynamic/write_conf_manuell
Executable file
@@ -0,0 +1,183 @@
|
||||
#!/bin/bash
|
||||
# Script um die cache_peer funktion von Squid manuell von der Website aus upzudaten.
|
||||
# V1.0
|
||||
# 13.10.2010
|
||||
# Stoeckholzer, Haas
|
||||
|
||||
while [ "1" == "1" ];
|
||||
do
|
||||
|
||||
write=1
|
||||
zero=0
|
||||
# ueberpruefen ob file vpnid_man vorhanden
|
||||
if [ -e /var/vpn/vpnid_man ];
|
||||
then
|
||||
echo 1
|
||||
zero=1
|
||||
fi
|
||||
|
||||
# ueberpruefen ob file vpnid_next vorhanden
|
||||
if [ -e /var/vpn/vpnid_next ];
|
||||
then
|
||||
echo 2
|
||||
zero=2
|
||||
fi
|
||||
|
||||
|
||||
|
||||
if [ "$zero" == "1" ];
|
||||
then
|
||||
# Manuelle ID als hex einlesen einlesen
|
||||
hex=$(cat /var/vpn/vpnid_man)
|
||||
id=$(printf "%d\n" 0x$hex)
|
||||
echo $id > /var/vpn/vpnid
|
||||
rm /var/vpn/vpnid_man
|
||||
echo $hex
|
||||
# Login-Daten aus Datenbank holen
|
||||
credentials=$(/home/christoph/squid_dynamic/squidy $hex)
|
||||
fi
|
||||
|
||||
if [ "$zero" == "2" ];
|
||||
then
|
||||
schleife="1"
|
||||
rm /var/vpn/vpnid_next
|
||||
|
||||
while [ $schleife == "1" ] ;
|
||||
do
|
||||
# Zaehlvariable einlesen
|
||||
id_alt=$(cat /var/vpn/vpnid)
|
||||
|
||||
# alte id HEX wandeln zum BLacklisten
|
||||
hex_alt=$(echo "obase=16; $id_alt" |bc)
|
||||
|
||||
# Abfrage ob Strinlaenge von hex kleiner als 2
|
||||
if [ ${#hex_alt} -lt 2 ];
|
||||
then
|
||||
hex_alt=0$hex_alt
|
||||
fi
|
||||
|
||||
# alte id BLacklisten
|
||||
if [ $write == 1 ];
|
||||
then
|
||||
echo $hex_alt >> /var/vpn/blacklist
|
||||
fi
|
||||
|
||||
# id inkrementieren
|
||||
let id=$id_alt+1
|
||||
|
||||
# 255 Overflow verhindern
|
||||
if [ $id -gt 254 ]
|
||||
then
|
||||
id=0
|
||||
fi
|
||||
|
||||
# Variable id fuer naechsten Durchlauf speichern
|
||||
echo $id > /var/vpn/vpnid
|
||||
|
||||
# id HEX wandeln
|
||||
hex=$(echo "obase=16; $id" |bc)
|
||||
|
||||
# Abfrage ob Strinlaenge von hex kleiner als 2
|
||||
if [ ${#hex} -lt 2 ];
|
||||
then
|
||||
hex=0$hex
|
||||
fi
|
||||
|
||||
# hole id_hex aus BLacklist?
|
||||
black=$(cat /var/vpn/blacklist|grep $hex)
|
||||
|
||||
# Abfrage ob id_hex in BLacklist
|
||||
if [ ${#black} -lt 2 ];
|
||||
then
|
||||
# Login-Daten aus Datenbank holen
|
||||
credentials=$(/home/christoph/squid_dynamic/squidy $hex)
|
||||
|
||||
# Abfrage ob Datensatz leer :
|
||||
if [ ${#credentials} -gt 10 ];
|
||||
then
|
||||
schleife="0"
|
||||
fi
|
||||
else write=0
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
# Abfrage ob Datensatz leer (zur Sicherheit):
|
||||
if [ ${#credentials} -gt 10 ] && [ $zero != "0" ];
|
||||
then
|
||||
|
||||
# stop squid
|
||||
sudo killall -9 unlinkd
|
||||
sudo killall -9 squid
|
||||
|
||||
sudo rm /etc/squid3/squid.conf
|
||||
######################################################################################
|
||||
# Config- Datei schreiben.
|
||||
sudo echo -e -n "
|
||||
# Squid config by h44z
|
||||
|
||||
# TAG: http_port
|
||||
# Usage: port
|
||||
# hostname:port
|
||||
# 1.2.3.4:port
|
||||
http_port 10.8.0.1:3128 transparent
|
||||
http_port 10.8.0.1:8080
|
||||
#https_port 10.8.0.1:8181 key=/etc/apache2/ssl/apache.pem
|
||||
|
||||
|
||||
visible_hostname vpnrack
|
||||
|
||||
# TAG: icp_port
|
||||
icp_port 0
|
||||
|
||||
# TAG: no_cache
|
||||
acl QUERY urlpath_regex cgi-bin \\?
|
||||
no_cache deny QUERY
|
||||
|
||||
# TAG: cache_mem (bytes)
|
||||
cache_mem 32 MB
|
||||
|
||||
# TAG: cache_dir
|
||||
cache_dir ufs /var/cache/squid 100 16 256
|
||||
|
||||
# TAG: cache_access_log
|
||||
cache_access_log /var/log/squid/access.log
|
||||
|
||||
# TAG: cache_log
|
||||
cache_log /var/log/squid/cache.log
|
||||
|
||||
# TAG: cache_store_log
|
||||
cache_store_log /var/log/squid/store.log
|
||||
|
||||
# TAG: emulate_httpd_log on|off
|
||||
emulate_httpd_log on
|
||||
|
||||
# TAG: pid_filename
|
||||
pid_filename /var/run/squid.pid
|
||||
|
||||
# TAG: cache_mgr
|
||||
cache_mgr christoph.haas2@students.htlinn.ac.at
|
||||
|
||||
http_access allow all
|
||||
acl https port 443
|
||||
http_access allow https
|
||||
|
||||
|
||||
# TAG: http_reply_access
|
||||
# Allow replies to client requests. This is complementary to http_access.
|
||||
#http_reply_access allow all
|
||||
|
||||
cache_peer 192.168.195.101 parent 8080 7 no-query default no-digest login=$credentials
|
||||
|
||||
never_direct allow all
|
||||
" > /etc/squid3/squid.conf
|
||||
######################################################################################
|
||||
|
||||
echo "Written: $credentials"
|
||||
|
||||
#start squid
|
||||
squid -D -YC -f /etc/squid3/squid.conf
|
||||
fi
|
||||
sleep 2
|
||||
done
|
158
Admin/Modules/Squid/squid_dynamic/write_conf_manuell.bak
Executable file
158
Admin/Modules/Squid/squid_dynamic/write_conf_manuell.bak
Executable file
@@ -0,0 +1,158 @@
|
||||
#!/bin/bash
|
||||
# Script um die cache_peer funktion von Squid manuell von der Website aus upzudaten.
|
||||
# V1.0
|
||||
# 13.10.2010
|
||||
# Stoeckholzer, Haas
|
||||
|
||||
while [ "1" == "1" ];
|
||||
do
|
||||
|
||||
zero=0
|
||||
# ueberpruefen ob file vpnid_man vorhanden
|
||||
if [ -e /var/vpn/vpnid_man ];
|
||||
then
|
||||
echo 1
|
||||
zero=1
|
||||
fi
|
||||
|
||||
# ueberpruefen ob file vpnid_next vorhanden
|
||||
if [ -e /var/vpn/vpnid_next ];
|
||||
then
|
||||
echo 2
|
||||
zero=2
|
||||
fi
|
||||
|
||||
|
||||
|
||||
if [ "$zero" == "1" ];
|
||||
then
|
||||
# Manuelle ID als hex einlesen einlesen
|
||||
hex=$(cat /var/vpn/vpnid_man)
|
||||
id=$(printf "%d\n" $hex)
|
||||
echo $id > /var/vpn/vpnid
|
||||
rm /var/vpn/vpnid_man
|
||||
echo $hex
|
||||
# Login-Daten aus Datenbank holen
|
||||
credentials=$(/home/christoph/squid_dynamic/squidy $hex)
|
||||
fi
|
||||
|
||||
if [ "$zero" == "2" ];
|
||||
then
|
||||
schleife="1"
|
||||
rm /var/vpn/vpnid_next
|
||||
|
||||
while [ $schleife == "1" ] ;
|
||||
do
|
||||
# Zaehlvariable einlesen
|
||||
id=$(cat /var/vpn/vpnid)
|
||||
# id inkrementieren
|
||||
let id=$id+1
|
||||
|
||||
# 255 Overflow verhindern
|
||||
if [ $id -gt 254 ]
|
||||
then
|
||||
id=0
|
||||
fi
|
||||
|
||||
# Variable id fuer naechsten Durchlauf speichern
|
||||
echo $id > /var/vpn/vpnid
|
||||
|
||||
# id HEX wandeln
|
||||
hex=$(echo "obase=16; $id" |bc)
|
||||
|
||||
# Abfrage ob Strinlaenge von hex kleiner als 2
|
||||
if [ ${#hex} -lt 2 ];
|
||||
then
|
||||
hex=0$hex
|
||||
fi
|
||||
|
||||
# Login-Daten aus Datenbank holen
|
||||
credentials=$(/home/christoph/squid_dynamic/squidy $hex)
|
||||
|
||||
# Abfrage ob Datensatz leer :
|
||||
if [ ${#credentials} -gt 10 ];
|
||||
then
|
||||
schleife="0"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
# Abfrage ob Datensatz leer (zur Sicherheit):
|
||||
if [ ${#credentials} -gt 10 ] && [ $zero != "0" ];
|
||||
then
|
||||
|
||||
# stop squid
|
||||
sudo killall -9 unlinkd
|
||||
sudo killall -9 squid
|
||||
|
||||
sudo rm /etc/squid3/squid.conf
|
||||
######################################################################################
|
||||
# Config- Datei schreiben.
|
||||
sudo echo -e -n "
|
||||
# Squid config by h44z
|
||||
|
||||
# TAG: http_port
|
||||
# Usage: port
|
||||
# hostname:port
|
||||
# 1.2.3.4:port
|
||||
http_port 10.8.0.1:3128 transparent
|
||||
http_port 10.8.0.1:8080
|
||||
#https_port 10.8.0.1:8181 key=/etc/apache2/ssl/apache.pem
|
||||
|
||||
|
||||
visible_hostname vpnrack
|
||||
|
||||
# TAG: icp_port
|
||||
icp_port 0
|
||||
|
||||
# TAG: no_cache
|
||||
acl QUERY urlpath_regex cgi-bin \\?
|
||||
no_cache deny QUERY
|
||||
|
||||
# TAG: cache_mem (bytes)
|
||||
cache_mem 32 MB
|
||||
|
||||
# TAG: cache_dir
|
||||
cache_dir ufs /var/cache/squid 100 16 256
|
||||
|
||||
# TAG: cache_access_log
|
||||
cache_access_log /var/log/squid/access.log
|
||||
|
||||
# TAG: cache_log
|
||||
cache_log /var/log/squid/cache.log
|
||||
|
||||
# TAG: cache_store_log
|
||||
cache_store_log /var/log/squid/store.log
|
||||
|
||||
# TAG: emulate_httpd_log on|off
|
||||
emulate_httpd_log on
|
||||
|
||||
# TAG: pid_filename
|
||||
pid_filename /var/run/squid.pid
|
||||
|
||||
# TAG: cache_mgr
|
||||
cache_mgr christoph.haas2@students.htlinn.ac.at
|
||||
|
||||
http_access allow all
|
||||
acl https port 443
|
||||
http_access allow https
|
||||
|
||||
|
||||
# TAG: http_reply_access
|
||||
# Allow replies to client requests. This is complementary to http_access.
|
||||
#http_reply_access allow all
|
||||
|
||||
cache_peer 192.168.195.101 parent 8080 7 no-query default no-digest login=$credentials
|
||||
|
||||
never_direct allow all
|
||||
" > /etc/squid3/squid.conf
|
||||
######################################################################################
|
||||
|
||||
echo "Written: $credentials"
|
||||
|
||||
#start squid
|
||||
squid -D -YC -f /etc/squid3/squid.conf
|
||||
fi
|
||||
sleep 2
|
||||
done
|
Reference in New Issue
Block a user