mirror of
https://github.com/Waujito/youtubeUnblock.git
synced 2024-12-22 14:26:11 +00:00
Fix warnings
This commit is contained in:
parent
2fd3107401
commit
c786a44dd5
@ -3,9 +3,9 @@
|
|||||||
#endif
|
#endif
|
||||||
#include "kmod_utils.h"
|
#include "kmod_utils.h"
|
||||||
|
|
||||||
|
#include <linux/kernel.h>
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/init.h>
|
#include <linux/init.h>
|
||||||
#include <linux/printk.h>
|
|
||||||
#include <linux/socket.h>
|
#include <linux/socket.h>
|
||||||
#include <linux/net.h>
|
#include <linux/net.h>
|
||||||
|
|
||||||
@ -143,7 +143,7 @@ int send_raw_socket(const uint8_t *pkt, uint32_t pktlen) {
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (pktlen > AVAILABLE_MTU) {
|
if (pktlen > AVAILABLE_MTU) {
|
||||||
pr_warn("The packet is too big and may cause issues!");
|
lgdebug("The packet is too big and may cause issues!");
|
||||||
|
|
||||||
NETBUF_ALLOC(buff1, MAX_PACKET_SIZE);
|
NETBUF_ALLOC(buff1, MAX_PACKET_SIZE);
|
||||||
if (!NETBUF_CHECK(buff1)) {
|
if (!NETBUF_CHECK(buff1)) {
|
||||||
@ -175,7 +175,7 @@ int send_raw_socket(const uint8_t *pkt, uint32_t pktlen) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
pr_warn("send_raw_socket: Packet is too big but fragmentation is disabled!");
|
pr_info("send_raw_socket: Packet is too big but fragmentation is disabled!");
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
goto erret_lc;
|
goto erret_lc;
|
||||||
}
|
}
|
||||||
@ -216,7 +216,7 @@ erret_lc:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void delay_packet_send(const unsigned char *data, unsigned int data_len, unsigned int delay_ms) {
|
void delay_packet_send(const unsigned char *data, unsigned int data_len, unsigned int delay_ms) {
|
||||||
pr_warn("delay_packet_send won't work on current youtubeUnblock version");
|
pr_info("delay_packet_send won't work on current youtubeUnblock version");
|
||||||
send_raw_socket(data, data_len);
|
send_raw_socket(data, data_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
// Make with make kmake && sudo iptables -t mangle -D OUTPUT 1 && sudo make kreload && sudo iptables -t mangle -I OUTPUT -p tcp -j YTUNBLOCK
|
// Make with make kmake && sudo iptables -t mangle -D OUTPUT 1 && sudo make kreload && sudo iptables -t mangle -I OUTPUT -p tcp -j YTUNBLOCK
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/init.h>
|
#include <linux/init.h>
|
||||||
#include <linux/printk.h>
|
|
||||||
#include <linux/mutex.h>
|
#include <linux/mutex.h>
|
||||||
#include <linux/socket.h>
|
#include <linux/socket.h>
|
||||||
#include <linux/net.h>
|
#include <linux/net.h>
|
||||||
|
@ -5,7 +5,8 @@
|
|||||||
#define LOG_LEVEL (config.verbose)
|
#define LOG_LEVEL (config.verbose)
|
||||||
|
|
||||||
#ifdef KERNEL_SPACE
|
#ifdef KERNEL_SPACE
|
||||||
#include <linux/printk.h>
|
#include <linux/kernel.h>
|
||||||
|
#include <linux/module.h>
|
||||||
#define printf pr_info
|
#define printf pr_info
|
||||||
#define perror pr_err
|
#define perror pr_err
|
||||||
#define lgerror(msg, ret, ...) __extension__ ({ \
|
#define lgerror(msg, ret, ...) __extension__ ({ \
|
||||||
|
24
mangle.c
24
mangle.c
@ -63,8 +63,6 @@ int process_packet(const uint8_t *raw_payload, uint32_t raw_payload_len) {
|
|||||||
|
|
||||||
accept:
|
accept:
|
||||||
return PKT_ACCEPT;
|
return PKT_ACCEPT;
|
||||||
drop:
|
|
||||||
return PKT_DROP;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int process_tcp_packet(const uint8_t *raw_payload, uint32_t raw_payload_len) {
|
int process_tcp_packet(const uint8_t *raw_payload, uint32_t raw_payload_len) {
|
||||||
@ -221,7 +219,7 @@ int process_tcp_packet(const uint8_t *raw_payload, uint32_t raw_payload_len) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case FRAG_STRAT_IP:
|
case FRAG_STRAT_IP:
|
||||||
if (ipxv != IP4VERSION) {
|
if (ipxv == IP4VERSION) {
|
||||||
ipd_offset = ((char *)data - (char *)tcph) + vrd.sni_offset;
|
ipd_offset = ((char *)data - (char *)tcph) + vrd.sni_offset;
|
||||||
mid_offset = ipd_offset + vrd.sni_len / 2;
|
mid_offset = ipd_offset + vrd.sni_len / 2;
|
||||||
mid_offset += 8 - mid_offset % 8;
|
mid_offset += 8 - mid_offset % 8;
|
||||||
@ -254,8 +252,10 @@ int process_tcp_packet(const uint8_t *raw_payload, uint32_t raw_payload_len) {
|
|||||||
goto drop_lc;
|
goto drop_lc;
|
||||||
} else {
|
} else {
|
||||||
printf("WARNING: IP fragmentation is supported only for IPv4\n");
|
printf("WARNING: IP fragmentation is supported only for IPv4\n");
|
||||||
|
goto default_send;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
default_send:
|
||||||
ret = instance_config.send_raw_packet(payload, payload_len);
|
ret = instance_config.send_raw_packet(payload, payload_len);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
lgerror("raw pack send", ret);
|
lgerror("raw pack send", ret);
|
||||||
@ -611,6 +611,7 @@ int post_fake_sni(const void *iph, unsigned int iph_len,
|
|||||||
}
|
}
|
||||||
|
|
||||||
lgtrace_addp("post fake sni #%d", i + 1);
|
lgtrace_addp("post fake sni #%d", i + 1);
|
||||||
|
lgtrace_addp("post with %d", fsn_len);
|
||||||
ret = instance_config.send_raw_packet(fake_sni, fsn_len);
|
ret = instance_config.send_raw_packet(fake_sni, fsn_len);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
lgerror("send fake sni", ret);
|
lgerror("send fake sni", ret);
|
||||||
@ -632,7 +633,7 @@ int post_fake_sni(const void *iph, unsigned int iph_len,
|
|||||||
memcpy(rfstcph, fstcph, tcph_len);
|
memcpy(rfstcph, fstcph, tcph_len);
|
||||||
fsiph = (void *)rfsiph;
|
fsiph = (void *)rfsiph;
|
||||||
fstcph = (void *)rfstcph;
|
fstcph = (void *)rfstcph;
|
||||||
out_lc:
|
|
||||||
NETBUF_FREE(fake_sni);
|
NETBUF_FREE(fake_sni);
|
||||||
continue;
|
continue;
|
||||||
erret_lc:
|
erret_lc:
|
||||||
@ -648,10 +649,6 @@ erret_lc:
|
|||||||
#define TLS_EXTENSION_SNI 0x0000
|
#define TLS_EXTENSION_SNI 0x0000
|
||||||
#define TLS_EXTENSION_CLIENT_HELLO_ENCRYPTED 0xfe0d
|
#define TLS_EXTENSION_CLIENT_HELLO_ENCRYPTED 0xfe0d
|
||||||
|
|
||||||
typedef uint8_t uint8_t;
|
|
||||||
typedef uint32_t uint32_t;
|
|
||||||
typedef uint16_t uint16_t;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Processes tls payload of the tcp request.
|
* Processes tls payload of the tcp request.
|
||||||
*
|
*
|
||||||
@ -672,9 +669,7 @@ struct tls_verdict analyze_tls_data(
|
|||||||
|
|
||||||
uint8_t tls_content_type = *msgData;
|
uint8_t tls_content_type = *msgData;
|
||||||
uint8_t tls_vmajor = *(msgData + 1);
|
uint8_t tls_vmajor = *(msgData + 1);
|
||||||
uint8_t tls_vminor = *(msgData + 2);
|
|
||||||
uint16_t message_length = ntohs(*(uint16_t *)(msgData + 3));
|
uint16_t message_length = ntohs(*(uint16_t *)(msgData + 3));
|
||||||
const uint8_t *message_length_ptr = msgData + 3;
|
|
||||||
|
|
||||||
if (tls_vmajor != 0x03) goto nextMessage;
|
if (tls_vmajor != 0x03) goto nextMessage;
|
||||||
|
|
||||||
@ -698,7 +693,6 @@ struct tls_verdict analyze_tls_data(
|
|||||||
|
|
||||||
const uint8_t *msgPtr = handshakeProto;
|
const uint8_t *msgPtr = handshakeProto;
|
||||||
msgPtr += 1;
|
msgPtr += 1;
|
||||||
const uint8_t *handshakeProto_length_ptr = msgPtr + 1;
|
|
||||||
msgPtr += 3 + 2 + 32;
|
msgPtr += 3 + 2 + 32;
|
||||||
|
|
||||||
if (msgPtr + 1 >= data_end) break;
|
if (msgPtr + 1 >= data_end) break;
|
||||||
@ -718,7 +712,6 @@ struct tls_verdict analyze_tls_data(
|
|||||||
|
|
||||||
if (msgPtr + 2 >= data_end) break;
|
if (msgPtr + 2 >= data_end) break;
|
||||||
uint16_t extensionsLen = ntohs(*(uint16_t *)msgPtr);
|
uint16_t extensionsLen = ntohs(*(uint16_t *)msgPtr);
|
||||||
const uint8_t *extensionsLen_ptr = msgPtr;
|
|
||||||
msgPtr += 2;
|
msgPtr += 2;
|
||||||
|
|
||||||
const uint8_t *extensionsPtr = msgPtr;
|
const uint8_t *extensionsPtr = msgPtr;
|
||||||
@ -735,7 +728,6 @@ struct tls_verdict analyze_tls_data(
|
|||||||
|
|
||||||
uint16_t extensionLen =
|
uint16_t extensionLen =
|
||||||
ntohs(*(uint16_t *)extensionPtr);
|
ntohs(*(uint16_t *)extensionPtr);
|
||||||
const uint8_t *extensionLen_ptr = extensionPtr;
|
|
||||||
extensionPtr += 2;
|
extensionPtr += 2;
|
||||||
|
|
||||||
|
|
||||||
@ -750,14 +742,13 @@ struct tls_verdict analyze_tls_data(
|
|||||||
if (sni_ext_ptr + 2 >= extensions_end) break;
|
if (sni_ext_ptr + 2 >= extensions_end) break;
|
||||||
uint16_t sni_ext_dlen = ntohs(*(uint16_t *)sni_ext_ptr);
|
uint16_t sni_ext_dlen = ntohs(*(uint16_t *)sni_ext_ptr);
|
||||||
|
|
||||||
const uint8_t *sni_ext_dlen_ptr = sni_ext_ptr;
|
|
||||||
sni_ext_ptr += 2;
|
sni_ext_ptr += 2;
|
||||||
|
|
||||||
const uint8_t *sni_ext_end = sni_ext_ptr + sni_ext_dlen;
|
const uint8_t *sni_ext_end = sni_ext_ptr + sni_ext_dlen;
|
||||||
if (sni_ext_end >= extensions_end) break;
|
if (sni_ext_end >= extensions_end) break;
|
||||||
|
|
||||||
if (sni_ext_ptr + 3 >= sni_ext_end) break;
|
if (sni_ext_ptr + 3 >= sni_ext_end) break;
|
||||||
uint8_t sni_type = *sni_ext_ptr++;
|
sni_ext_ptr++;
|
||||||
uint16_t sni_len = ntohs(*(uint16_t *)sni_ext_ptr);
|
uint16_t sni_len = ntohs(*(uint16_t *)sni_ext_ptr);
|
||||||
sni_ext_ptr += 2;
|
sni_ext_ptr += 2;
|
||||||
|
|
||||||
@ -947,7 +938,6 @@ int gen_fake_sni(const void *ipxh, uint32_t iph_len,
|
|||||||
memcpy(buf + iph_len, tcph, tcph_len);
|
memcpy(buf + iph_len, tcph, tcph_len);
|
||||||
memcpy(buf + iph_len + tcph_len, data, data_len);
|
memcpy(buf + iph_len + tcph_len, data, data_len);
|
||||||
|
|
||||||
struct tcphdr *ntcph = (struct tcphdr *)(buf + iph_len);
|
|
||||||
|
|
||||||
if (ipxv == IP4VERSION) {
|
if (ipxv == IP4VERSION) {
|
||||||
struct iphdr *niph = (struct iphdr *)buf;
|
struct iphdr *niph = (struct iphdr *)buf;
|
||||||
@ -993,8 +983,6 @@ int fail_packet(uint8_t *payload, uint32_t *plen, uint32_t avail_buflen) {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sizedelta = 0;
|
|
||||||
|
|
||||||
|
|
||||||
if (config.faking_strategy == FAKE_STRAT_RAND_SEQ) {
|
if (config.faking_strategy == FAKE_STRAT_RAND_SEQ) {
|
||||||
lgtrace("fake seq: %u -> ", ntohl(tcph->seq));
|
lgtrace("fake seq: %u -> ", ntohl(tcph->seq));
|
||||||
|
@ -38,14 +38,6 @@
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
/*
|
|
||||||
* Sorry, I don't have headers for RHEL 6 and below because I'm in a bit of a
|
|
||||||
* deadline right now.
|
|
||||||
* If this is causing you trouble, find `nf_hookfn` in your kernel headers
|
|
||||||
* (typically in include/linux/netfilter.h) and add your version of the
|
|
||||||
* NF_CALLBACK macro here.
|
|
||||||
* Also, kernel headers per version can be found here: http://vault.centos.org/
|
|
||||||
*/
|
|
||||||
#error "Sorry; this version of RHEL is not supported because it's kind of old."
|
#error "Sorry; this version of RHEL is not supported because it's kind of old."
|
||||||
|
|
||||||
#endif /* RHEL_RELEASE_CODE >= x */
|
#endif /* RHEL_RELEASE_CODE >= x */
|
||||||
|
8
types.h
8
types.h
@ -8,14 +8,6 @@
|
|||||||
#include <linux/string.h> // IWYU pragma: export
|
#include <linux/string.h> // IWYU pragma: export
|
||||||
|
|
||||||
#include <linux/types.h>
|
#include <linux/types.h>
|
||||||
typedef __u8 uint8_t;
|
|
||||||
typedef __u16 uint16_t;
|
|
||||||
typedef __u32 uint32_t;
|
|
||||||
typedef __u64 uint64_t;
|
|
||||||
//typedef __i8 int8_t;
|
|
||||||
//typedef __i16 int16_t;
|
|
||||||
//typedef __i32 int32_t;
|
|
||||||
//typedef __i64 int64_t;
|
|
||||||
#else /* USER_SPACE */
|
#else /* USER_SPACE */
|
||||||
|
|
||||||
#include <errno.h> // IWYU pragma: export
|
#include <errno.h> // IWYU pragma: export
|
||||||
|
Loading…
Reference in New Issue
Block a user