Skip to content

Commit

Permalink
Update comments
Browse files Browse the repository at this point in the history
  • Loading branch information
iyangsj committed Aug 1, 2019
1 parent f064997 commit 8175356
Show file tree
Hide file tree
Showing 28 changed files with 38 additions and 40 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ BFE is an open-source layer 7 load balancer derived from proprietary Baidu Front
- [Plugin](docs/en_us/modules.md)

## Contributing
- Please create an issue in [issue list] (http://github.com/baidu/bfe/issues).
- Please create an issue in [issue list](http://github.com/baidu/bfe/issues).
- Contact Committers/Owners for further discussion if needed.
- Following the golang coding standards.
- See the [CONTRIBUTING](CONTRIBUTING.md) file for details
Expand Down
2 changes: 1 addition & 1 deletion bfe_balance/backend/health_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import (
)

func UpdateStatus(backend *BfeBackend, cluster string) bool {
// get conf of health check, which is seperately stored for each cluster
// get conf of health check, which is separately stored for each cluster
checkConf := getCheckConf(cluster)
if checkConf == nil {
// just ingore if not found health check conf
Expand Down
4 changes: 2 additions & 2 deletions bfe_balance/bal_slb/bal_rr.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

// weighted round robin balance
//
// Alogrithm:
// Algorithm:
// smooth Weighted Round Robin algorithm is as follows: on each backend selection,
// 1. increase CurrentWeight of each eligible backend by its weight,
// 2. select backend with greatest CurrentWeight and reduce its CurrentWeight
Expand Down Expand Up @@ -54,7 +54,7 @@ import (
"github.com/baidu/bfe/bfe_debug"
)

// implementation versions of weighted round robin alogrithm
// implementation versions of weighted round robin algorithm
const (
WrrSimple = 0
WrrSmooth = 1
Expand Down
2 changes: 1 addition & 1 deletion bfe_balance/bal_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func (t *BalTable) backendInit(backendConfs cluster_table_conf.ClusterTableConf)
continue
}

// initalize
// initialize
err := bal.BackendInit(backendConf)
if err != nil {
log.Logger.Error("ClusterTable.backendInit():err[%s] in cluster.BackendInit() for %s",
Expand Down
2 changes: 1 addition & 1 deletion bfe_basic/error_code.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ var (
ErrBkNoBackend = errors.New("BK_NO_BACKEND") // no backend found
ErrBkRequestBackend = errors.New("BK_REQUEST_BACKEND") // forward request to backend error
ErrBkConnectBackend = errors.New("BK_CONNECT_BACKEND") // connect backend error
ErrBkWriteRequest = errors.New("BK_WRITE_REQUEST") // write request error (casued by bk or client)
ErrBkWriteRequest = errors.New("BK_WRITE_REQUEST") // write request error (caused by bk or client)
ErrBkReadRespHeader = errors.New("BK_READ_RESP_HEADER") // read response error
ErrBkRespHeaderTimeout = errors.New("BK_RESP_HEADER_TIMEOUT") // read response timeout
ErrBkTransportBroken = errors.New("BK_TRANSPORT_BROKEN") // conn broken
Expand Down
2 changes: 1 addition & 1 deletion bfe_config/bfe_conf/conf_https_basic.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ type ConfigHttpsBasic struct {
TlsRuleConf string // config for server tls rule

CipherSuites []string // supported cipher suites
CurvePreferences []string // curve perference
CurvePreferences []string // curve preference

MaxTlsVersion string // max tls version supported
MinTlsVersion string // min tls version supported
Expand Down
4 changes: 2 additions & 2 deletions bfe_config/bfe_conf/conf_session_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ type ConfigSessionCache struct {
// disable tls session cache or not
SessionCacheDisabled bool

// tcp address for redis servers
Servers string // one server or multiply servers(seperated by ',')
// address for redis servers
Servers string

// perfix for cache key
KeyPrefix string
Expand Down
14 changes: 5 additions & 9 deletions bfe_http/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ type Request struct {
// following a hyphen uppercase and the rest lowercase.
Header Header

// a headerKeys represents keys of header in orginal order
// a headerKeys represents keys of header in original order
HeaderKeys textproto.MIMEKeys

// Body is the request's body.
Expand Down Expand Up @@ -213,7 +213,7 @@ type Request struct {
TLS *bfe_tls.ConnectionState

// State allows HTTP server and other software to record
// infomation about the request. This filed may be not filled.
// information about the request. This filed may be not filled.
State *RequestState
}

Expand Down Expand Up @@ -394,7 +394,7 @@ func (req *Request) write(w io.Writer, usingProxy bool, extraHeaders Header) err
ruri = host
} else {
// use req.RequestUri instead of req.URL.RequestURI() (decoded/encoded)
// to be compatiable with non-standard web server ONLY WHEN URL not changed since
// to be compatible with non-standard web server ONLY WHEN URL not changed since
// ReadRequest()
rawurl, err := url.ParseRequestURI(req.RequestURI)
if err == nil && rawurl.RequestURI() == ruri {
Expand Down Expand Up @@ -454,7 +454,7 @@ func (req *Request) write(w io.Writer, usingProxy bool, extraHeaders Header) err

// flush req header immediately if w if a buffered writer.
// in case that the backend read timeout setting is too short,
// and body receiving from client is too slow, so until backend timeout the buffer is not fufilled
// and body receiving from client is too slow, so until backend timeout the buffer is not fulfilled
// and the backend may close the connection
if rbw, ok := w.(Flusher); ok {
err = rbw.Flush()
Expand Down Expand Up @@ -937,11 +937,7 @@ func (r *Request) WantsHttp10KeepAlive() bool {
return false
}

// change http 1.0 keepalive to ignore header Connection, keep consistent with c-bfe
// just for simplify comparasion in the process of replace bfe
// TODO: after replacement finish, change back
//return HasToken(r.Header.GetDirect("Connection"), "keep-alive")
return false
return HasToken(r.Header.GetDirect("Connection"), "keep-alive")
}

func (r *Request) WantsClose() bool {
Expand Down
2 changes: 1 addition & 1 deletion bfe_module/bfe_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func ModConfDir(confRoot string, modName string) string {
return confDir
}

// ModuleStatusGetJson get modules Availabe and modules Enabled.
// ModuleStatusGetJson get modules Available and modules Enabled.
func ModuleStatusGetJson() ([]byte, error) {
status := make(map[string][]string)
status["available"] = modulesAll
Expand Down
4 changes: 2 additions & 2 deletions bfe_modules/mod_header/mod_header.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func (m *ModuleHeader) reqHeaderHandler(request *bfe_basic.Request) (int, *bfe_h
// apply global rule first
m.applyProductRule(request, ReqHeader, GlobalProduct)

// product specific rule will overwirte global rule for HEADER_SET action
// product specific rule will overwrite global rule for HEADER_SET action
m.applyProductRule(request, ReqHeader, request.Route.Product)

return bfe_module.BFE_HANDLER_GOON, nil
Expand All @@ -151,7 +151,7 @@ func (m *ModuleHeader) rspHeaderHandler(request *bfe_basic.Request, res *bfe_htt
// apply global rule first
m.applyProductRule(request, RspHeader, GlobalProduct)

// product specific rule will overwirte global rule for HEADER_SET action
// product specific rule will overwrite global rule for HEADER_SET action
m.applyProductRule(request, RspHeader, request.Route.Product)

return bfe_module.BFE_HANDLER_GOON
Expand Down
2 changes: 1 addition & 1 deletion bfe_modules/mod_redirect/action_url.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func ReqUrlFromQuery(req *bfe_basic.Request, key string) {
req.Redirect.Url = req.Query.Get(key)
}

// ReqUrlPrefixAdd specify redirect url by adding prefix to orginal uri(path+query)
// ReqUrlPrefixAdd specify redirect url by adding prefix to original uri(path+query)
// e.g., url "/(.*)" => "link$1",
func ReqUrlPrefixAdd(req *bfe_basic.Request, prefix string) {
rawUrl := req.HttpRequest.URL
Expand Down
2 changes: 1 addition & 1 deletion bfe_net/textproto/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ package textproto
// keys to sets of values.
type MIMEHeader map[string][]string

// A MIMEKyes represents keys of header in orginal order
// A MIMEKyes represents keys of header in original order
type MIMEKeys []string

// Add adds the key, value pair to the header.
Expand Down
2 changes: 1 addition & 1 deletion bfe_net/textproto/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ func (r *Reader) ReadMIMEHeaderAndKeys() (MIMEHeader, MIMEKeys, error) {
m[key] = append(vv, value)
}

// append key in orginal order
// append key in original order
mkeys = append(mkeys, key)

if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions bfe_server/bfe_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ func (srv *BfeServer) initTLSConfig() (err error) {
// enable Sslv2 ClientHello for compatible with ancient TLS-capable clients
srv.TLSConfig.EnableSslv2ClientHello = httpsConf.EnableSslv2ClientHello

// initialize ciphersuites perference
// initialize ciphersuites preference
srv.TLSConfig.PreferServerCipherSuites = true
cipherSuites, cipherSuitesPriority, err := bfe_conf.GetCipherSuites(httpsConf.CipherSuites)
if err != nil {
Expand All @@ -219,7 +219,7 @@ func (srv *BfeServer) initTLSConfig() (err error) {
// set Ssl3PoodleProofed true make server free of poodle attach
srv.TLSConfig.Ssl3PoodleProofed = true

// initialize elliptic curves perference
// initialize elliptic curves preference
srv.TLSConfig.CurvePreferences, err = bfe_conf.GetCurvePreferences(httpsConf.CurvePreferences)
if err != nil {
return fmt.Errorf("in ServerCertConfLoad() :%s", err.Error())
Expand Down
2 changes: 1 addition & 1 deletion bfe_server/bfe_server_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func StartUp(cfg bfe_conf.BfeConfig, version string, confRoot string) error {
}
log.Logger.Info("StartUp(): bfeServer.InitDataLoad() OK")

// start embeded web server
// start embedded web server
bfeServer.Monitor.Start()

serveChan := make(chan error)
Expand Down
2 changes: 1 addition & 1 deletion bfe_server/http_conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const (
// Close the connection after send response to client.
closeAfterReply
// Close the connection directly, do not send any data,
// it usally means some attacks may happened.
// it usually means some attacks may happened.
closeDirectly
)

Expand Down
2 changes: 1 addition & 1 deletion bfe_server/protocol_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func NewProtocolHandler(conn *conn, proto string) *ProtocolHandler {
// ServeHTTP processes http request and send http response.
//
// Params:
// - w : a reponse writer
// - w : a response writer
// - r : a http request
func (p *ProtocolHandler) ServeHTTP(rw bfe_http.ResponseWriter, request *bfe_http.Request) {
log.Logger.Debug("ProtocolHandler(%s): start process request", p.proto)
Expand Down
2 changes: 1 addition & 1 deletion bfe_server/register_modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"github.com/baidu/go-lib/log"
)

// RegisterModule registeres bfe work module.
// RegisterModule registers bfe work module.
func (srv *BfeServer) RegisterModules(modules []string) error {
if modules == nil {
return nil
Expand Down
2 changes: 1 addition & 1 deletion bfe_server/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func srcIsRegularFile(src io.Reader) (isRegular bool, err error) {
}
}

// set signature calculater for response
// set signature calculator for response
func (w *response) SetSigner(signer bfe_http.SignCalculater) {
w.cw.Signer = signer
}
Expand Down
2 changes: 1 addition & 1 deletion bfe_server/reverseproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ func (p *ReverseProxy) ServeHTTP(rw bfe_http.ResponseWriter, basicReq *bfe_basic
// get instance of BfeServer
srv := p.server

// set clientip of orginal user for request
// set clientip of original user for request
setClientAddr(basicReq)

// Callback for HANDLE_BEFORE_LOCATION
Expand Down
2 changes: 1 addition & 1 deletion bfe_server/tls_server_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ type TLSServerRuleMap struct {
vipRuleMap map[string]*ServerRule // tls server rule for specified conn
sniRuleMap map[string]*ServerRule // tls server rule for specified host (optional)

nextProtosDef *NextProtosConf // defualt next protos conf
nextProtosDef *NextProtosConf // default next protos conf
enableHttp2 bool // enable http2 globally or not
enableSpdy bool // enable spdy globally or not
chacha20Def bool // default chacha20 conf
Expand Down
2 changes: 1 addition & 1 deletion bfe_server/tls_session_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ type ServerSessionCache struct {
KeyPrefix string // prefix for cache key

SessionExpire int // expire time for tls session state (s)
MaxIdle int // max idle conenctions in pool
MaxIdle int // max idle connections in pool
pool *redis.Pool // connection pool to redis server
poolLock sync.RWMutex // lock for pool

Expand Down
2 changes: 1 addition & 1 deletion bfe_server/web_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// embeded web server in bfe
// embedded web server in bfe

package bfe_server

Expand Down
4 changes: 2 additions & 2 deletions bfe_tls/handshake_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ func runClientTestTLS12(t *testing.T, template *clientTest) {
func prepareClientConfig() *Config {
config := testConfig.Clone()

// Note: for avoid modify exsiting data file under testdata dir,
// Note: for avoid modify existing data file under testdata dir,
// client should only use required ciphersuites.
config.CipherSuites = []uint16{
TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
Expand Down Expand Up @@ -348,7 +348,7 @@ func TestHandshakeClientECDHEECDSAAESGCM(t *testing.T) {
}

func prepareClientConfigForChacha20() *Config {
// Note: for avoid modify exsiting data file under testdata dir,
// Note: for avoid modify existing data file under testdata dir,
// client should only use required ciphersuites.
ciphers := []uint16{
TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256,
Expand Down
2 changes: 1 addition & 1 deletion bfe_tls/handshake_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ Curves:
}
} else {
// Although sending an NPN extension without h2 is reasonable, some client
// has a bug aroud this. Best to send NPN without h2.
// has a bug around this. Best to send NPN without h2.
nextProtos = checkAndRemoveH2(nextProtos)

// Although sending an empty NPN extension is reasonable, Firefox has
Expand Down
2 changes: 1 addition & 1 deletion bfe_util/logid.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ uint64_t calculate_log_id(char *network, char* client_addr, char* local_addr,
return log_id;
}
*/
import "C" // this line must be seperated
import "C" // this line must be separated

import (
"net"
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
golang.org/x/crypto v0.0.0-20190530122614-20be4c3c3ed5
golang.org/x/net v0.0.0-20190620200207-3b0461eec859
golang.org/x/sys v0.0.0-20190602015325-4c4f7f33c9ed
golang.org/x/tools v0.0.0-20190730215328-ed3277de2799 // indirect
golang.org/x/tools v0.0.0-20190731214159-1e85ed8060aa // indirect
gopkg.in/gcfg.v1 v1.2.3
gopkg.in/warnings.v0 v0.1.2 // indirect
)
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ golang.org/x/sys v0.0.0-20190602015325-4c4f7f33c9ed/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/tools v0.0.0-20190730215328-ed3277de2799 h1:rvNf5qrBjmtxebJHK+blZSkGIv+Yg6UlDnl2ApkB6m4=
golang.org/x/tools v0.0.0-20190730215328-ed3277de2799/go.mod h1:jcCCGcm9btYwXyDqrUWc6MKQKKGJCWEQ3AfLSRIbEuI=
golang.org/x/tools v0.0.0-20190731214159-1e85ed8060aa h1:kwa/4M1dbmhZqOIqYiTtbA6JrvPwo1+jqlub2qDXX90=
golang.org/x/tools v0.0.0-20190731214159-1e85ed8060aa/go.mod h1:jcCCGcm9btYwXyDqrUWc6MKQKKGJCWEQ3AfLSRIbEuI=
gopkg.in/gcfg.v1 v1.2.3 h1:m8OOJ4ccYHnx2f4gQwpno8nAX5OGOh7RLaaz0pj3Ogs=
gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o=
gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=
Expand Down

0 comments on commit 8175356

Please sign in to comment.