Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
obfs4portscan
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Legacy
gitolite
user
phw
obfs4portscan
Commits
77c2826c
Unverified
Commit
77c2826c
authored
5 years ago
by
Philipp Winter
Browse files
Options
Downloads
Plain Diff
Merge branch 'fix/30472'
parents
45ad51f0
b60bafce
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
README.md
+4
-2
4 additions, 2 deletions
README.md
handlers.go
+6
-6
6 additions, 6 deletions
handlers.go
main.go
+23
-7
23 additions, 7 deletions
main.go
with
33 additions
and
15 deletions
README.md
+
4
−
2
View file @
77c2826c
...
...
@@ -4,8 +4,10 @@ publicly reachable.
## Command line arguments arguments
The tool takes as input two command line arguments: a path to a certificate
file and a path to its key file, both in PEM format. We use these files to run
the HTTPS server.
file (specified by the argument
`-cert-file`
) and a path to its key file
(specified by the argument
`-key-file`
), both in PEM format. We use these
files to run the HTTPS server. An optional third argument (
`-addr`
) can be used
to specify the address and port to listen on.
## Scanning method
We try to establish a TCP connection with the given IP address and port using
...
...
This diff is collapsed.
Click to expand it.
handlers.go
+
6
−
6
View file @
77c2826c
...
...
@@ -8,6 +8,10 @@ import (
"time"
)
// timeout specifies the number of seconds we're willing to wait until we
// decide that the given destination is offline.
const
timeout
time
.
Duration
=
3
*
time
.
Second
// limiter implements a rate limiter. We allow 1 request per second on average
// with bursts of up to 5 requests per second.
var
limiter
=
rate
.
NewLimiter
(
1
,
5
)
...
...
@@ -38,10 +42,6 @@ func ScanDestination(w http.ResponseWriter, r *http.Request) {
return
}
// The number of seconds we're willing to wait until we decide that the
// given destination is offline.
timeout
,
_
:=
time
.
ParseDuration
(
"3s"
)
r
.
ParseForm
()
// These variables will be "" if they're not set.
address
:=
r
.
Form
.
Get
(
"address"
)
...
...
@@ -56,7 +56,7 @@ func ScanDestination(w http.ResponseWriter, r *http.Request) {
return
}
portReachable
,
err
:=
IsTCPPortReachable
(
address
,
port
,
timeout
)
portReachable
,
err
:=
IsTCPPortReachable
(
address
,
port
)
if
portReachable
{
SendResponse
(
w
,
SuccessPage
)
}
else
{
...
...
@@ -67,7 +67,7 @@ func ScanDestination(w http.ResponseWriter, r *http.Request) {
// IsTCPPortReachable returns `true' if it can establish a TCP connection with
// the given IP address and port. If not, it returns `false' and the
// respective error, as reported by `net.DialTimeout'.
func
IsTCPPortReachable
(
addr
,
port
string
,
timeout
time
.
Duration
)
(
bool
,
error
)
{
func
IsTCPPortReachable
(
addr
,
port
string
)
(
bool
,
error
)
{
conn
,
err
:=
net
.
DialTimeout
(
"tcp"
,
fmt
.
Sprintf
(
"%s:%s"
,
addr
,
port
),
timeout
)
if
err
!=
nil
{
...
...
This diff is collapsed.
Click to expand it.
main.go
+
23
−
7
View file @
77c2826c
package
main
import
(
"fmt"
"flag"
"io"
"log"
"net/http"
"os"
"time"
"git.torproject.org/pluggable-transports/snowflake.git/common/safelog"
"github.com/gorilla/mux"
)
...
...
@@ -76,13 +78,27 @@ func Logger(inner http.Handler, name string) http.Handler {
// main is the entry point of this tool.
func
main
()
{
if
len
(
os
.
Args
)
!=
3
{
fmt
.
Printf
(
"Usage: %s CERT_FILE KEY_FILE
\n
"
,
os
.
Args
[
0
])
os
.
Exit
(
1
)
var
certFile
string
var
keyFile
string
var
addr
string
flag
.
StringVar
(
&
certFile
,
"cert-file"
,
""
,
"Path to the certificate to use, in .pem format."
)
flag
.
StringVar
(
&
keyFile
,
"key-file"
,
""
,
"Path to the certificate's private key, in .pem format."
)
flag
.
StringVar
(
&
addr
,
"addr"
,
":443"
,
"Address to listen on."
)
flag
.
Parse
()
var
logOutput
io
.
Writer
=
os
.
Stderr
// We want to send the log output through our scrubber first
log
.
SetOutput
(
&
safelog
.
LogScrubber
{
Output
:
logOutput
})
log
.
SetFlags
(
log
.
LstdFlags
|
log
.
LUTC
)
if
certFile
==
""
{
log
.
Fatalf
(
"The -cert-file argument is required."
)
}
if
keyFile
==
""
{
log
.
Fatalf
(
"The -key-file argument is required."
)
}
certFile
:=
os
.
Args
[
1
]
keyFile
:=
os
.
Args
[
2
]
router
:=
NewRouter
()
log
.
Fatal
(
http
.
ListenAndServeTLS
(
":8080"
,
certFile
,
keyFile
,
router
))
log
.
Fatal
(
http
.
ListenAndServeTLS
(
addr
,
certFile
,
keyFile
,
router
))
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment