mirror of
https://github.com/yarrick/iodine.git
synced 2024-11-21 15:05:15 +00:00
Fixed #47, support any TAP device name
This commit is contained in:
parent
f20b3c9511
commit
e59aaa523e
@ -7,6 +7,7 @@ CHANGES:
|
||||
|
||||
20xx-xx-xx: x.y.z
|
||||
- Fixed tunnel not working on Windows.
|
||||
- Any device name is now supported on Windows, fixes #47.
|
||||
|
||||
2009-06-01: 0.5.2 "WifiFree"
|
||||
- Fixed client segfault on OS X, #57
|
||||
|
@ -15,14 +15,12 @@ Extra README file for Win32 related stuff
|
||||
|
||||
2. Have one TAP32 interface installed
|
||||
|
||||
3. Name the interface "dns"
|
||||
3. Make sure the interface does not have a default gateway set
|
||||
|
||||
4. Make sure the interface does not have a default gateway set
|
||||
|
||||
5. Run iodine/iodined as normal (see the main README file).
|
||||
4. Run iodine/iodined as normal (see the main README file).
|
||||
You may have to run it as administrator depending on user privileges.
|
||||
|
||||
6. Enjoy!
|
||||
5. Enjoy!
|
||||
|
||||
|
||||
== Building on Windows:
|
||||
@ -50,7 +48,6 @@ cross-compile.
|
||||
== Results of crappy Win32 API:
|
||||
The following fixable limitations apply:
|
||||
- Exactly one TAP32 interface must be installed
|
||||
- The TAP32 interface must be named "dns" and be version 0801 or 0901
|
||||
- Server cannot read packet destination address
|
||||
|
||||
The following (probably) un-fixable limitations apply:
|
||||
|
@ -740,7 +740,8 @@ handshake_raw_udp(int dns_fd, int seed)
|
||||
r = select(dns_fd + 1, &fds, NULL, NULL, &tv);
|
||||
|
||||
if(r > 0) {
|
||||
len = read(dns_fd, in, sizeof(in));
|
||||
/* recv() needed for windows, dont change to read() */
|
||||
len = recv(dns_fd, in, sizeof(in), 0);
|
||||
if (len >= (17 + RAW_HDR_LEN)) {
|
||||
char hash[16];
|
||||
login_calculate(hash, 16, password, seed - 1);
|
||||
|
39
src/tun.c
39
src/tun.c
@ -37,6 +37,7 @@ struct tun_data data;
|
||||
#define TAP_IOCTL_SET_MEDIA_STATUS TAP_CONTROL_CODE(6, METHOD_BUFFERED)
|
||||
|
||||
#define TAP_ADAPTER_KEY "SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002BE10318}"
|
||||
#define NETWORK_KEY "SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}"
|
||||
#define TAP_DEVICE_SPACE "\\\\.\\Global\\"
|
||||
#define TAP_VERSION_ID_0801 "tap0801"
|
||||
#define TAP_VERSION_ID_0901 "tap0901"
|
||||
@ -53,7 +54,7 @@ struct tun_data data;
|
||||
#include "tun.h"
|
||||
#include "common.h"
|
||||
|
||||
char if_name[50];
|
||||
char if_name[250];
|
||||
|
||||
#ifndef WINDOWS32
|
||||
#ifdef LINUX
|
||||
@ -227,6 +228,36 @@ next:
|
||||
RegCloseKey(adapter_key);
|
||||
}
|
||||
|
||||
static void
|
||||
get_name(char *dev_name)
|
||||
{
|
||||
char path[256];
|
||||
char name_str[256] = "Name";
|
||||
LONG status;
|
||||
HKEY conn_key;
|
||||
DWORD len;
|
||||
DWORD datatype;
|
||||
|
||||
memset(if_name, 0, sizeof(if_name));
|
||||
|
||||
snprintf(path, sizeof(path), NETWORK_KEY "\\%s\\Connection", dev_name);
|
||||
status = RegOpenKeyEx(HKEY_LOCAL_MACHINE, path, 0, KEY_READ, &conn_key);
|
||||
printf("%s ?? %s\n", path, dev_name);
|
||||
if (status != ERROR_SUCCESS) {
|
||||
fprintf(stderr, "Could not look up name of interface %s: error opening key\n", dev_name);
|
||||
RegCloseKey(conn_key);
|
||||
return;
|
||||
}
|
||||
len = sizeof(if_name);
|
||||
status = RegQueryValueEx(conn_key, name_str, NULL, &datatype, (LPBYTE)if_name, &len);
|
||||
if (status != ERROR_SUCCESS || datatype != REG_SZ) {
|
||||
fprintf(stderr, "Could not look up name of interface %s: error reading value\n", dev_name);
|
||||
RegCloseKey(conn_key);
|
||||
return;
|
||||
}
|
||||
RegCloseKey(conn_key);
|
||||
}
|
||||
|
||||
DWORD WINAPI tun_reader(LPVOID arg)
|
||||
{
|
||||
struct tun_data *tun = arg;
|
||||
@ -265,8 +296,9 @@ open_tun(const char *tun_device)
|
||||
|
||||
memset(adapter, 0, sizeof(adapter));
|
||||
get_device(adapter, sizeof(adapter));
|
||||
get_name(adapter); /* Copies interface 'human name' to if_name */
|
||||
|
||||
if (strlen(adapter) == 0) {
|
||||
if (strlen(adapter) == 0 || strlen(if_name) == 0) {
|
||||
warnx("No TAP adapters found. See README-win32.txt for help.\n");
|
||||
return -1;
|
||||
}
|
||||
@ -278,9 +310,6 @@ open_tun(const char *tun_device)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* TODO get name of interface */
|
||||
strncpy(if_name, "dns", MIN(4, sizeof(if_name)));
|
||||
|
||||
/* Use a UDP connection to forward packets from tun,
|
||||
* so we can still use select() in main code.
|
||||
* A thread does blocking reads on tun device and
|
||||
|
Loading…
Reference in New Issue
Block a user