mirror of
https://github.com/Waujito/youtubeUnblock.git
synced 2025-12-30 19:28:08 +03:00
Update kmod logging
This commit is contained in:
66
kytunblock.c
66
kytunblock.c
@@ -38,7 +38,7 @@ static int open_raw_socket(void) {
|
||||
ret = sock_create(AF_INET, SOCK_RAW, IPPROTO_RAW, &rawsocket);
|
||||
|
||||
if (ret < 0) {
|
||||
pr_alert("Unable to create raw socket\n");
|
||||
lgerror(ret, "Unable to create raw socket\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ static int open_raw6_socket(void) {
|
||||
ret = sock_create(AF_INET6, SOCK_RAW, IPPROTO_RAW, &raw6socket);
|
||||
|
||||
if (ret < 0) {
|
||||
pr_alert("Unable to create raw socket\n");
|
||||
lgerror(ret, "Unable to create raw socket\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
@@ -219,7 +219,7 @@ erret_lc:
|
||||
}
|
||||
|
||||
static int delay_packet_send(const unsigned char *data, unsigned int data_len, unsigned int delay_ms) {
|
||||
pr_info("delay_packet_send won't work on current youtubeUnblock version");
|
||||
lginfo("delay_packet_send won't work on current youtubeUnblock version");
|
||||
return send_raw_socket(data, data_len);
|
||||
}
|
||||
|
||||
@@ -350,41 +350,51 @@ static int __init ykb_init(void) {
|
||||
ret = open_raw_socket();
|
||||
if (ret < 0) goto err;
|
||||
|
||||
|
||||
if (config.use_ipv6) {
|
||||
ret = open_raw6_socket();
|
||||
if (ret < 0) goto close_rawsocket;
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,13,0)
|
||||
struct net *n;
|
||||
for_each_net(n) {
|
||||
ret = nf_register_net_hook(n, &ykb6_nf_reg);
|
||||
if (ret < 0)
|
||||
lgerror(ret, "bad rat");
|
||||
}
|
||||
#else
|
||||
nf_register_hook(&ykb6_nf_reg);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,13,0)
|
||||
struct net *n;
|
||||
|
||||
for_each_net(n) {
|
||||
ret = nf_register_net_hook(n, &ykb_nf_reg);
|
||||
if (ret < 0)
|
||||
lgerror(ret, "bad rat");
|
||||
if (ret < 0) {
|
||||
lgerror(ret, "register net_hook");
|
||||
}
|
||||
}
|
||||
#else
|
||||
nf_register_hook(&ykb_nf_reg);
|
||||
ret = nf_register_hook(&ykb_nf_reg);
|
||||
if (ret < 0) {
|
||||
lgerror(ret, "register net_hook");
|
||||
}
|
||||
#endif
|
||||
|
||||
pr_info("youtubeUnblock kernel module started.\n");
|
||||
|
||||
if (config.use_ipv6) {
|
||||
ret = open_raw6_socket();
|
||||
if (ret < 0) {
|
||||
config.use_ipv6 = 0;
|
||||
lgwarning("ipv6 disabled!");
|
||||
goto ipv6_fallback;
|
||||
}
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,13,0)
|
||||
struct net *n;
|
||||
for_each_net(n) {
|
||||
ret = nf_register_net_hook(n, &ykb6_nf_reg);
|
||||
if (ret < 0) {
|
||||
lgerror(ret, "register net6_hook");
|
||||
}
|
||||
}
|
||||
#else
|
||||
ret = nf_register_hook(&ykb6_nf_reg);
|
||||
if (ret < 0) {
|
||||
lgerror(ret, "register net6_hook");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
ipv6_fallback:
|
||||
lginfo("youtubeUnblock kernel module started.\n");
|
||||
return 0;
|
||||
|
||||
close_rawsocket:
|
||||
close_raw_socket();
|
||||
err:
|
||||
return ret;
|
||||
}
|
||||
@@ -410,7 +420,7 @@ static void __exit ykb_destroy(void) {
|
||||
#endif
|
||||
|
||||
close_raw_socket();
|
||||
pr_info("youtubeUnblock kernel module destroyed.\n");
|
||||
lginfo("youtubeUnblock kernel module destroyed.\n");
|
||||
}
|
||||
|
||||
module_init(ykb_init);
|
||||
|
||||
Reference in New Issue
Block a user