mirror of
https://github.com/ChronosX88/netsukuku.git
synced 2024-11-25 03:32:20 +00:00
Oh, My, GOD! You may think I was just doing afk the past week or so, But, You'd be wrong, So, So, SO wrong. I've spent almost every day working as hard as I can on this commit here. It should work perfectly now, It should properly exclude interfaces, And, It should automatically exclude inactive ones. More testing is needed, Especially testing of running the -e argument multiple times, I.E -e eth0 -e wlan0. Anyway, Thank you for reading, And for downloading.
This commit is contained in:
parent
a7bbd6dff7
commit
27f363f9b1
1
Vagrant/Vagrantfile
vendored
1
Vagrant/Vagrantfile
vendored
@ -97,6 +97,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
|||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install nasm make build-essential grub qemu zip -y
|
sudo apt-get install nasm make build-essential grub qemu zip -y
|
||||||
sudo apt-get install git vde2 zlibc libgmp-dev openssl libssl-dev libgee-dev libpth-dev libgcrypt11-dev autoconf cmake autogen mawk gawk
|
sudo apt-get install git vde2 zlibc libgmp-dev openssl libssl-dev libgee-dev libpth-dev libgcrypt11-dev autoconf cmake autogen mawk gawk
|
||||||
|
sudo vde_switch -t tap0 -t tap1 -d
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -327,32 +327,59 @@ void free_server_opt(void)
|
|||||||
void exclude_interface(void) {
|
void exclude_interface(void) {
|
||||||
char *ifs = "null1";
|
char *ifs = "null1";
|
||||||
char *old_tmp = "null2";
|
char *old_tmp = "null2";
|
||||||
|
char *old_tmp1 = "null3";
|
||||||
struct ifaddrs *addrs,*tmp;
|
struct ifaddrs *addrs,*tmp;
|
||||||
struct ifreq *a_ifs;
|
|
||||||
getifaddrs(&addrs);
|
if (getifaddrs(&addrs) !=0) {
|
||||||
|
printf("%s\n", strerror(errno));
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
tmp = addrs;
|
tmp = addrs;
|
||||||
while(tmp) {
|
while(tmp) {
|
||||||
|
|
||||||
old_tmp = ifs;
|
old_tmp = ifs;
|
||||||
|
|
||||||
if(tmp->ifa_addr && tmp->ifa_addr->sa_family == AF_PACKET)
|
Re_Check:
|
||||||
|
|
||||||
|
old_tmp1 = ifs;
|
||||||
|
if(tmp && tmp->ifa_addr && tmp->ifa_addr->sa_family == AF_PACKET && tmp->ifa_flags & IFF_UP)
|
||||||
ifs = tmp->ifa_name;
|
ifs = tmp->ifa_name;
|
||||||
|
|
||||||
if(strncmp(ifs, "lo", 2) == 0 || strncmp(ifs, "tunl0", 5) == 0 || strncmp(ifs, "tunl1", 5) == 0 || strcmp(ifs, optarg) == 0)
|
else if(tmp && strcmp(old_tmp1, ifs) == 0) {
|
||||||
goto Check_Active;
|
|
||||||
|
|
||||||
Check_Active:
|
|
||||||
|
|
||||||
a_ifs = ifs;
|
|
||||||
if(a_ifs->ifr_name != IFF_UP) {
|
|
||||||
tmp = tmp->ifa_next;
|
tmp = tmp->ifa_next;
|
||||||
if(tmp->ifa_addr && tmp->ifa_addr->sa_family == AF_PACKET)
|
goto Re_Check;
|
||||||
|
}
|
||||||
|
|
||||||
|
Re_Check1:
|
||||||
|
|
||||||
|
printf("Possibly bad ifs is: %s\n", ifs);
|
||||||
|
|
||||||
|
if(tmp && (strncmp(ifs, "lo", 2) == 0 || strncmp(ifs, "tunl0", 5) == 0 || strncmp(ifs, "tunl1", 5) == 0 || strcmp(optarg, ifs) == 0)) {
|
||||||
|
printf("Bad Interface: %s\n", ifs);
|
||||||
|
tmp = tmp->ifa_next;
|
||||||
|
old_tmp1 = ifs;
|
||||||
|
if(tmp && tmp->ifa_addr && tmp->ifa_addr->sa_family == AF_PACKET && tmp->ifa_flags & IFF_UP)
|
||||||
ifs = tmp->ifa_name;
|
ifs = tmp->ifa_name;
|
||||||
|
|
||||||
|
if(tmp && strcmp(old_tmp1, ifs) == 0) {
|
||||||
|
tmp = tmp->ifa_next;
|
||||||
|
|
||||||
|
if(tmp && tmp->ifa_addr && tmp->ifa_addr->sa_family == AF_PACKET && tmp->ifa_flags & IFF_UP)
|
||||||
|
ifs = tmp->ifa_name;
|
||||||
|
goto Re_Check1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("Good ifs is: %s\n", ifs);
|
||||||
|
|
||||||
|
if(strcmp(old_tmp, ifs) == 0) {
|
||||||
|
printf("Loop finished: %s\n", ifs);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
tmp = tmp->ifa_next;
|
tmp = tmp->ifa_next;
|
||||||
if(strcmp(old_tmp, ifs) == 0)
|
|
||||||
break;
|
|
||||||
server_opt.ifs[server_opt.ifs_n++]=xstrndup(ifs, IFNAMSIZ-1);
|
server_opt.ifs[server_opt.ifs_n++]=xstrndup(ifs, IFNAMSIZ-1);
|
||||||
|
printf("Using Interface: %s\n", ifs);
|
||||||
}
|
}
|
||||||
|
|
||||||
freeifaddrs(addrs);
|
freeifaddrs(addrs);
|
||||||
|
Loading…
Reference in New Issue
Block a user