Skip to content

Commit

Permalink
Merge pull request #4 from go-httpproxy/develop
Browse files Browse the repository at this point in the history
v1.3
  • Loading branch information
orkunkaraduman authored Feb 16, 2018
2 parents 7a6ed94 + 9449c44 commit 56cce93
Show file tree
Hide file tree
Showing 13 changed files with 885 additions and 678 deletions.
22 changes: 13 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type Proxy struct {
UserData interface{}

// Error handler.
OnError func(ctx *Context, when string, err *Error, opErr error)
OnError func(ctx *Context, where string, err *Error, opErr error)

// Accept handler. It greets proxy request like ServeHTTP function of
// http.Handler.
Expand All @@ -43,7 +43,7 @@ type Proxy struct {

// Auth handler. If you need authentication, set this handler.
// If it returns true, authentication succeeded.
OnAuth func(ctx *Context, user string, pass string) bool
OnAuth func(ctx *Context, authType string, user string, pass string) bool

// Connect handler. It sets connect action and new host.
// If len(newhost) > 0, host changes.
Expand Down Expand Up @@ -83,14 +83,18 @@ type Context struct {
// Sub session number of processing remote connection.
SubSessionNo int64

// Action of after the CONNECT, if proxy request method is CONNECT.
// Original Proxy request.
// It's using internally. Don't change in Context struct!
ConnectAction ConnectAction
Req *http.Request

// Proxy request, if proxy request method is CONNECT.
// Original Proxy request, if proxy request method is CONNECT.
// It's using internally. Don't change in Context struct!
ConnectReq *http.Request

// Action of after the CONNECT, if proxy request method is CONNECT.
// It's using internally. Don't change in Context struct!
ConnectAction ConnectAction

// Remote host, if proxy request method is CONNECT.
// It's using internally. Don't change in Context struct!
ConnectHost string
Expand All @@ -100,7 +104,7 @@ type Context struct {
}
```

### Demo code
### Simple code

```go
package main
Expand All @@ -112,10 +116,10 @@ import (
"github.com/go-httpproxy/httpproxy"
)

func OnError(ctx *httpproxy.Context, when string,
func OnError(ctx *httpproxy.Context, where string,
err *httpproxy.Error, opErr error) {
// Log errors.
log.Printf("ERR: %s: %s [%s]", when, err, opErr)
log.Printf("ERR: %s: %s [%s]", where, err, opErr)
}

func OnAccept(ctx *httpproxy.Context, w http.ResponseWriter,
Expand All @@ -128,7 +132,7 @@ func OnAccept(ctx *httpproxy.Context, w http.ResponseWriter,
return false
}

func OnAuth(ctx *httpproxy.Context, user string, pass string) bool {
func OnAuth(ctx *httpproxy.Context, authType string, user string, pass string) bool {
// Auth test user.
if user == "test" && pass == "1234" {
return true
Expand Down
236 changes: 0 additions & 236 deletions ca.go

This file was deleted.

Loading

0 comments on commit 56cce93

Please sign in to comment.