Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
T
tun
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Railgun
tun
Commits
6ef1826c
Commit
6ef1826c
authored
Jun 30, 2022
by
Manni
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
added standard parameter format.
parent
c4ee0fee
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
19 deletions
+46
-19
main.cpp
main.cpp
+46
-19
No files found.
main.cpp
View file @
6ef1826c
...
...
@@ -44,30 +44,57 @@ void outbound(int raw, int tun) {
perror
(
"outbound read"
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
ifreq
ifr
{};
ifr
.
ifr_flags
=
IFF_TUN
|
IFF_NO_PI
;
void
show_usage
()
{
printf
(
"Usage Help:
\n\n
"
);
printf
(
"-i <IP>: IP to connect
\n
"
);
printf
(
"-h: show this usage help"
);
return
;
}
auto
raw
=
socket
(
AF_INET
,
SOCK_RAW
,
IPPROTO_IPIP
);
if
(
raw
<
0
){
perror
(
"socket init error"
);
int
main
(
int
argc
,
char
*
argv
[])
{
if
(
argc
<=
1
){
printf
(
"Wrong usage! Type -h to see usage help."
);
return
0
;
}
auto
tun
=
open
(
"/dev/net/tun"
,
O_RDWR
);
if
(
tun
<
0
){
perror
(
"tun init error"
)
;
if
(
argv
[
1
]
==
"-h"
){
show_usage
();
return
0
;
}
if
(
argv
[
1
]
==
"-i"
){
ifreq
ifr
{};
ifr
.
ifr_flags
=
IFF_TUN
|
IFF_NO_PI
;
auto
raw
=
socket
(
AF_INET
,
SOCK_RAW
,
IPPROTO_IPIP
);
if
(
raw
<
0
){
perror
(
"socket init error"
);
return
-
1
;
}
auto
tun
=
open
(
"/dev/net/tun"
,
O_RDWR
);
if
(
tun
<
0
){
perror
(
"tun init error"
);
return
-
1
;
}
if
(
ioctl
(
tun
,
TUNSETIFF
,
&
ifr
)
<
0
){
perror
(
"ioctl error"
);
}
if
(
ioctl
(
tun
,
TUNSETIFF
,
&
ifr
)
<
0
){
perror
(
"ioctl error"
);
return
-
1
;
}
remote
=
inet_addr
(
argv
[
1
]);
remote
=
inet_addr
(
argv
[
2
]);
std
::
cout
<<
raw
<<
std
::
endl
;
std
::
cout
<<
tun
<<
std
::
endl
;
std
::
cout
<<
raw
<<
std
::
endl
;
std
::
cout
<<
tun
<<
std
::
endl
;
std
::
thread
t1
(
inbound
,
raw
,
tun
);
std
::
thread
t2
(
outbound
,
raw
,
tun
);
t1
.
join
();
t2
.
join
();
std
::
thread
t1
(
inbound
,
raw
,
tun
);
std
::
thread
t2
(
outbound
,
raw
,
tun
);
t1
.
join
();
t2
.
join
();
return
0
;
}
else
{
printf
(
"Wrong usage! Type -h to see usage help."
);
return
0
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment