mirror of
https://github.com/yarrick/iodine.git
synced 2024-11-23 18:15:13 +00:00
#89, use remote ip as second ip in ifconfig on FreeBSD
This commit is contained in:
parent
8e5d75e426
commit
a4f41b7db3
@ -1492,7 +1492,7 @@ handshake_login(int dns_fd, int seed)
|
||||
|
||||
server[64] = 0;
|
||||
client[64] = 0;
|
||||
if (tun_setip(client, netmask) == 0 &&
|
||||
if (tun_setip(client, server, netmask) == 0 &&
|
||||
tun_setmtu(mtu) == 0) {
|
||||
|
||||
fprintf(stderr, "Server tunnel IP is %s\n", server);
|
||||
|
@ -2409,12 +2409,14 @@ main(int argc, char **argv)
|
||||
read_password(password, sizeof(password));
|
||||
}
|
||||
|
||||
created_users = init_users(my_ip, netmask);
|
||||
|
||||
if ((tun_fd = open_tun(device)) == -1) {
|
||||
retval = 1;
|
||||
goto cleanup0;
|
||||
}
|
||||
if (!skipipconfig) {
|
||||
if (tun_setip(argv[0], netmask) != 0 || tun_setmtu(mtu) != 0) {
|
||||
if (tun_setip(argv[0], users_get_first_ip(), netmask) != 0 || tun_setmtu(mtu) != 0) {
|
||||
retval = 1;
|
||||
goto cleanup1;
|
||||
}
|
||||
@ -2432,8 +2434,6 @@ main(int argc, char **argv)
|
||||
|
||||
my_mtu = mtu;
|
||||
|
||||
created_users = init_users(my_ip, netmask);
|
||||
|
||||
if (created_users < USERS) {
|
||||
fprintf(stderr, "Limiting to %d simultaneous users because of netmask /%d\n",
|
||||
created_users, netmask);
|
||||
|
@ -426,7 +426,7 @@ read_tun(int tun_fd, char *buf, size_t len)
|
||||
}
|
||||
|
||||
int
|
||||
tun_setip(const char *ip, int netbits)
|
||||
tun_setip(const char *ip, const char *remoteip, int netbits)
|
||||
{
|
||||
char cmdline[512];
|
||||
int netmask;
|
||||
@ -458,7 +458,11 @@ tun_setip(const char *ip, int netbits)
|
||||
"/sbin/ifconfig %s %s %s netmask %s",
|
||||
if_name,
|
||||
ip,
|
||||
#ifdef FREEBSD
|
||||
remoteip, /* FreeBSD wants other IP as second IP */
|
||||
#else
|
||||
ip,
|
||||
#endif
|
||||
inet_ntoa(net));
|
||||
|
||||
fprintf(stderr, "Setting IP of %s to %s\n", if_name, ip);
|
||||
|
@ -21,7 +21,7 @@ int open_tun(const char *);
|
||||
void close_tun(int);
|
||||
int write_tun(int, char *, size_t);
|
||||
ssize_t read_tun(int, char *, size_t);
|
||||
int tun_setip(const char *, int);
|
||||
int tun_setip(const char *, const char *, int);
|
||||
int tun_setmtu(const unsigned);
|
||||
|
||||
#endif /* _TUN_H_ */
|
||||
|
@ -85,6 +85,14 @@ init_users(in_addr_t my_ip, int netbits)
|
||||
return created_users;
|
||||
}
|
||||
|
||||
const char*
|
||||
users_get_first_ip()
|
||||
{
|
||||
struct in_addr ip;
|
||||
ip.s_addr = users[0].tun_ip;
|
||||
return inet_ntoa(ip);
|
||||
}
|
||||
|
||||
int
|
||||
users_waiting_on_reply()
|
||||
{
|
||||
|
@ -76,6 +76,7 @@ struct user {
|
||||
extern struct user users[USERS];
|
||||
|
||||
int init_users(in_addr_t, int);
|
||||
const char* users_get_first_ip();
|
||||
int users_waiting_on_reply();
|
||||
int find_user_by_ip(uint32_t);
|
||||
int all_users_waiting_to_send();
|
||||
|
Loading…
Reference in New Issue
Block a user