add list-ciphers option

This commit is contained in:
Vladislav Yarmak 2021-02-26 09:09:55 +02:00
parent 6dd28baf6b
commit 0725d27faf
6 changed files with 510 additions and 498 deletions

15
auth.go
View File

@ -1,16 +1,16 @@
package main
import (
"os"
"bufio"
"crypto/subtle"
"encoding/base64"
"errors"
"golang.org/x/crypto/bcrypt"
"net/http"
"net/url"
"errors"
"strings"
"os"
"strconv"
"encoding/base64"
"crypto/subtle"
"golang.org/x/crypto/bcrypt"
"bufio"
"strings"
)
const AUTH_REQUIRED_MSG = "Proxy authentication required.\n"
@ -188,7 +188,6 @@ func (_ NoAuth) Validate(wr http.ResponseWriter, req *http.Request) bool {
return true
}
type CertAuth struct{}
func (_ CertAuth) Validate(wr http.ResponseWriter, req *http.Request) bool {

View File

@ -1,8 +1,8 @@
package main
import (
"log"
"fmt"
"log"
)
const (

View File

@ -1,13 +1,13 @@
package main
import (
"net"
"context"
"fmt"
"time"
"net"
"net/http"
"strings"
"context"
"sync"
"time"
)
type ProxyHandler struct {

View File

@ -1,8 +1,8 @@
package main
import (
"io"
"errors"
"io"
"time"
)

21
main.go
View File

@ -1,12 +1,13 @@
package main
import (
"log"
"os"
"fmt"
"crypto/tls"
"flag"
"time"
"fmt"
"log"
"net/http"
"os"
"time"
)
func perror(msg string) {
@ -27,8 +28,14 @@ type CLIArgs struct {
verbosity int
timeout time.Duration
cert, key, cafile string
list_suites bool
}
func list_suites() {
for _, cipher := range tls.CipherSuites() {
fmt.Println(cipher.Name)
}
}
func parse_args() CLIArgs {
var args CLIArgs
@ -40,6 +47,7 @@ func parse_args() CLIArgs {
flag.StringVar(&args.cert, "cert", "", "enable TLS and use certificate")
flag.StringVar(&args.key, "key", "", "key for TLS certificate")
flag.StringVar(&args.cafile, "cafile", "", "CA file to authenticate clients with certificates")
flag.BoolVar(&args.list_suites, "list-ciphers", false, "list ciphersuites")
flag.Parse()
return args
}
@ -47,6 +55,11 @@ func parse_args() CLIArgs {
func run() int {
args := parse_args()
if args.list_suites {
list_suites()
return 0
}
logWriter := NewLogWriter(os.Stderr)
defer logWriter.Close()

View File

@ -1,17 +1,17 @@
package main
import (
"context"
"net"
"sync"
"io"
"time"
"errors"
"net/http"
"bufio"
"context"
"crypto/tls"
"crypto/x509"
"errors"
"io"
"io/ioutil"
"net"
"net/http"
"sync"
"time"
)
const COPY_BUF = 128 * 1024