Permalink
Browse files

Rename repoClient to repoBridge

Signed-off-by: Patrick Uiterwijk <patrick@puiterwijk.org>
  • Loading branch information...
puiterwijk committed Aug 8, 2018
1 parent 445fe9c commit ca07e0490fd124083ea027e3897c4fd1c5f06029
@@ -1,6 +1,6 @@
# Binaries for programs and plugins
/repospanner
/repoclient
/repobridge
/repohookrunner
*.exe
*.dll
@@ -95,7 +95,7 @@ http.sslkey=/etc/pki/repospanner/someuser.key
https://nodea.regiona.repospanner.local/repo/test.git".

Alternatively, for ssh based pushing and pulling, make sure that the users'
entry console is the `repoclient` binary, and the client_config.yml file is setup
entry console is the `repobridge` binary, and the client_config.yml file is setup
in /etc/repospanner.
This client will automatically revert to plain git if it determines the repo
that is being pushed to is not a repospanner repository.
@@ -13,7 +13,7 @@ The RPC endpoint is used for communication between different nodes and within a
It has very low-level calls that could bring the system in an inconsistent state by performing invalid requests.
It can be firewalled so that only the other nodes and each node itself can communicate to it.

The user endpoint is used for requests by user clients (be that Git, repoclient, or any other client).
The user endpoint is used for requests by user clients (be that Git, repobridge, or any other client).
TLS client certificates are optional, although unauthenticated requests are only able to clone public repositories and get the high-level version information of the system.
This endpoint should be available from clients who need access to the repositories on this system.

@@ -1,4 +1,4 @@
package client
package bridge

import (
"crypto/tls"
@@ -20,26 +20,26 @@ func getClient() *http.Client {

cert, key := getCertAndKey()

clientcert, err := tls.LoadX509KeyPair(
bridgecert, err := tls.LoadX509KeyPair(
cert,
key,
)
checkError(err, "Error initializing client")
checkError(err, "Error initializing bridge")

var certpool *x509.CertPool
capath := configuration.Ca
if capath != "" {
cts, err := ioutil.ReadFile(capath)
checkError(err, "Error initializing client ca")
checkError(err, "Error initializing bridge ca")
certpool = x509.NewCertPool()
if ok := certpool.AppendCertsFromPEM(cts); !ok {
exitWithError("Error initializing client ca")
exitWithError("Error initializing bridge ca")
}
}

transport := &http.Transport{
TLSClientConfig: &tls.Config{
Certificates: []tls.Certificate{clientcert},
Certificates: []tls.Certificate{bridgecert},
NextProtos: []string{"h2"},
PreferServerCipherSuites: true,
MinVersion: tls.VersionTLS12,
@@ -60,7 +60,7 @@ func getURL(service, reponame string) string {
}

func bridge(r *http.Request) {
r.Header["X-RepoClient-Version"] = []string{constants.VersionString()}
r.Header["X-RepoBridge-Version"] = []string{constants.VersionString()}

resp, err := getClient().Do(r)
checkError(
@@ -1,19 +1,19 @@
// +build !nonh2

package client
package bridge

import (
"net/http"

"golang.org/x/net/http2"
)

// HasH2 returns whether this client was compiled with h2 support
// HasH2 returns whether this bridge was compiled with h2 support
func HasH2() bool {
return true
}

func maybeConfigureH2(transport *http.Transport) {
err := http2.ConfigureTransport(transport)
checkError(err, "Error initializing HTTP/2 transport")
}
}
@@ -1,16 +1,16 @@
// +build nonh2

package client
package bridge

import (
"net/http"
)

// HasH2 returns whether this client was compiled with h2 support
// HasH2 returns whether this bridge was compiled with h2 support
func HasH2() bool {
return false
}

func maybeConfigureH2(transport *http.Transport) {
// Not configuring h2
}
}
@@ -1,4 +1,4 @@
package client
package bridge

import (
"bytes"
@@ -112,17 +112,17 @@ func isRawGitRepo(path string) (rawgit bool, gsname string, err error) {
}

func loadConfig() {
cfgFile := os.Getenv("REPOCLIENT_CONFIG")
cfgFile := os.Getenv("REPOBRIDGE_CONFIG")
if cfgFile=="" {
cfgFile = "/etc/repospanner/client_config.json"
cfgFile = "/etc/repospanner/bridge_config.json"
}
cts, err := ioutil.ReadFile(cfgFile)
checkError(err, "Error reading configuration")
err = json.Unmarshal(cts, &configuration)
checkError(err, "Error parsing configuration")
}

func ExecuteClient() {
func ExecuteBridge() {
username = os.Getenv("USER")
if username == "" {
exitWithError("Unable to determine username")
@@ -218,6 +218,6 @@ func getCertAndKey() (string, string) {
}

// Seems there was no configuration for this user, nor default... Abandon all hope
exitWithError("User does not have access to this client")
exitWithError("User does not have access to this bridge")
return "", ""
}
File renamed without changes.
@@ -15,11 +15,11 @@ export GITDESCRIP="`git describe --long --tags --dirty --always`"
-o ../../repospanner
)
(
cd cmd/repoclient/
cd cmd/repobridge/
go build -ldflags \
"-X repospanner.org/repospanner/server/constants.version=$VERSION
-X repospanner.org/repospanner/server/constants.gitdescrip=$GITDESCRIP" \
-o ../../repoclient
-o ../../repobridge
)
(
cd cmd/repohookrunner/
@@ -5,7 +5,7 @@ import (
"log"
"os"

"repospanner.org/repospanner/client"
"repospanner.org/repospanner/bridge"
"repospanner.org/repospanner/server/constants"
)

@@ -15,14 +15,14 @@ func main() {
os.Exit(1)
}
if len(os.Args) == 1 {
fmt.Println("repoSpanner client " + constants.PublicVersionString())
if client.HasH2() {
fmt.Println("This client is HTTP/2 enabled")
fmt.Println("repoSpanner bridge " + constants.PublicVersionString())
if bridge.HasH2() {
fmt.Println("This bridge is HTTP/2 enabled")
} else {
fmt.Println("This client is deprived of HTTP/2 goodness")
fmt.Println("This bridge is deprived of HTTP/2 goodness")
}
os.Exit(0)
}

client.ExecuteClient()
bridge.ExecuteBridge()
}
@@ -20,7 +20,7 @@ import (

var (
binary string
clientbinary string
bridgebinary string
hookrunnerbinary string
)

@@ -33,22 +33,22 @@ func checkFileExist(t *testing.T, path string) {
}

func setBinaryPaths(t *testing.T) {
if binary != "" && clientbinary != "" {
if binary != "" && bridgebinary != "" {
return
}
codedir, err := os.Getwd()
failIfErr(t, err, "determining binary paths")
codedir = filepath.Join(codedir, "..")
possiblebinary := filepath.Join(codedir, "repospanner")
possibleclientbinary := filepath.Join(codedir, "repoclient")
possiblebridgebinary := filepath.Join(codedir, "repobridge")
possiblehookrunnerbinary := filepath.Join(codedir, "repohookrunner")

checkFileExist(t, possiblebinary)
checkFileExist(t, possibleclientbinary)
checkFileExist(t, possiblebridgebinary)
checkFileExist(t, possiblehookrunnerbinary)

binary = possiblebinary
clientbinary = possibleclientbinary
bridgebinary = possiblebridgebinary
hookrunnerbinary = possiblehookrunnerbinary

atleast110, sure := service.IsAtLeastGo110(runtime.Version())
@@ -146,7 +146,7 @@ func _runRawCommand(t *testing.T, binname, pwd string, envupdates []string, args
envupdates = append(
envupdates,
"USER=admin",
"REPOCLIENT_CONFIG="+pwd+".json",
"REPOBRIDGE_CONFIG="+pwd+".json",
)
cmd := exec.Command(
binname,
@@ -199,14 +199,8 @@ func runForTestedCloneMethods(t *testing.T, m func(*testing.T, cloneMethod)) {
}
}

func createSSHClientConfig(t *testing.T, node nodeNrType, confpath string) {
err := os.Mkdir(path.Join(testDir, "clientlogs"), 0755)
if os.IsExist(err) {
err = nil
}
failIfErr(t, err, "creating client logs folder")

examplecfgB, err := ioutil.ReadFile("../client_config.json.example")
func createSSHBridgeConfig(t *testing.T, node nodeNrType, confpath string) {
examplecfgB, err := ioutil.ReadFile("../bridge_config.json.example")
failIfErr(t, err, "reading example config")
examplecfg := string(examplecfgB)

@@ -217,12 +211,6 @@ func createSSHClientConfig(t *testing.T, node nodeNrType, confpath string) {
path.Join(testDir, "ca"),
-1,
)
examplecfg = strings.Replace(
examplecfg,
"/var/log/repospanner_client/",
path.Join(testDir, "clientlogs"),
-1,
)
examplecfg = strings.Replace(
examplecfg,
"debug: false",
@@ -245,15 +233,15 @@ func createSSHClientConfig(t *testing.T, node nodeNrType, confpath string) {
// Write generated config file
examplecfgB = []byte(examplecfg)
err = ioutil.WriteFile(confpath, examplecfgB, 0644)
failIfErr(t, err, "writing client config file")
failIfErr(t, err, "writing bridge config file")

t.Log("Client config for", node, confpath, examplecfg)
t.Log("Bridge config for", node, confpath, examplecfg)
}

func cloneCmdSSH(t *testing.T, node nodeNrType, reponame, username string) (cmd []string, envupdates []string) {
cmd = []string{
"clone",
"ext::" + clientbinary + " " + reponame,
"ext::" + bridgebinary + " " + reponame,
}

return
@@ -295,7 +283,7 @@ func clone(t *testing.T, method cloneMethod, node nodeNrType, reponame, username
ourdir, err := ioutil.TempDir(cloneDir, fmt.Sprintf("clone_%s_%s_", reponame, username))
failIfErr(t, err, "creating clone directory")

createSSHClientConfig(t, node, ourdir+".json")
createSSHBridgeConfig(t, node, ourdir+".json")

var cmd []string
var envupdates []string
@@ -18,7 +18,7 @@ func (cfg *Service) serveGitDiscovery(w http.ResponseWriter, r *http.Request, pe
http.NotFound(w, r)
return
}
isrepoclient := len(r.Header[http.CanonicalHeaderKey("X-RepoClient-Version")]) == 1
isrepobridge := len(r.Header[http.CanonicalHeaderKey("X-RepoBridge-Version")]) == 1
service := services[0]
w.Header()["Content-Type"] = []string{"application/x-" + service + "-advertisement"}
reqlogger = reqlogger.WithField("service", service)
@@ -35,7 +35,7 @@ func (cfg *Service) serveGitDiscovery(w http.ResponseWriter, r *http.Request, pe

w.WriteHeader(200)

if !isrepoclient {
if !isrepobridge {
if err := sendPacket(w, []byte("# service="+service+"\n")); err != nil {
http.NotFound(w, r)
return
@@ -67,10 +67,10 @@ func findProjectAndOp(parts []string) (string, string) {
func (cfg *Service) ServeHTTP(w http.ResponseWriter, r *http.Request) {
reqlogger, perminfo := cfg.prereq(w, r, "gitservice")

repoclient := r.Header[http.CanonicalHeaderKey("X-RepoClient-Version")]
if len(repoclient) != 0 {
repobridge := r.Header[http.CanonicalHeaderKey("X-RepoBridge-Version")]
if len(repobridge) != 0 {
reqlogger = reqlogger.WithField(
"RepoClient-Version", repoclient,
"RepoBridge-Version", repobridge,
)
}

0 comments on commit ca07e04

Please sign in to comment.