Giter VIP home page Giter VIP logo

sdk-golang's Introduction

Ziggy using the sdk-golang

Ziti SDK for Golang

The OpenZiti SDK for GoLang allows developers to create their own custom OpenZiti network endpoint clients and management tools. OpenZiti is a modern, programmable network overlay with associated edge components, for application-embedded, zero trust network connectivity, written by developers for developers. The SDK harnesses that power via APIs that allow developers to imagine and develop solutions beyond what OpenZiti handles by default.

This SDK does the following:

Table of Contents

Important Packages

This repository has a number of different folders, however below are the most important ones for a new developer to be aware of.

  • ziti - the main SDK package that will be included in your project
  • edge-apis - provides low-level abstractions for authenticating and accessing the Ziti Edge Client and Management APIs
  • example - various example applications that illustrate different uses of the SDK. Each example contains its own README.md.
    • chat - a bare-bones example of a client and server for a chat program over an OpenZiti Service
    • chat-p2p - highlights addressable terminators which allows clients to dial specific services hosts if there are multiple hosts
    • curlz - wrapping existing network tooling (curl) to work over OpenZiti
    • grpc-example - using GRPC over OpenZiti
    • http-client - a HTTP client accessing a web server over HTTP
    • jwtchat - highlights using external JWTs ( from OIDC/oAuth/etc.) to authenticate with OpenZIti
    • reflect - a low level network "echo" client and server example
    • simple-server - a bare-bones HTTP server side only example
    • zcat - wrapping existing network tooling (netcat) to work over OpenZiti
    • zping - wrapping existing network tooling (ping) to work over OpenZiti

Writing Your Own Endpoint Client

An "endpoint client" in OpenZiti's language is an identity that is dialing (accessing) or binding (hosting) a service. Dialing contacts either another identity hosting a service, which may be another client endpoint, or it may be handled by an Edge Router depending on its termination configuration. This SDK supports binding and dialing, which means it can host or access services depending on what it is instructed to do and the policies affecting the software's identity and service(s).

To test a client endpoint you will need the following outside your normal Golang development environment:

  1. An OpenZiti Network with controller with at least one Edge Router (See Quick Starts)
  2. A service to dial (access) and bind (host) (See Allowing Dial/Bind Access To A Service)
  3. An identity for your client to test with (See Creating & Enrolling a Dial Identity)

The steps for writing any endpoint client are:

  1. Load/Create a configuration
  2. Create a instance
  3. Dial/Bind a service

The above links provide the steps in more detail, but here is the most basic setup to dial a service with most error handling removed for brevity:

	cfg, _ := ziti.NewConfigFromFile("client.json")
	
	context, _ := ziti.NewContext(cfg)
	
	conn, _ := context.Dial(serviceName)
	
	if _, err := conn.Write([]byte("hello I am myTestClient")); err != nil {
		panic(err)
	}

Load/Create A Configuration

Configuration can be done through a file or through code that creates a Config instance. Loading through a file support x509 authentication only while creating custom Config instances allows for all authentication methods (x509, Username/Password, JWT, etc.).

The easiest way to create a configuration is by using the ziti edge enroll capabilities that will generate an identity file that provides the location of the OpenZiti controller, the configuration types the client is interested in, and the x509 certificate and private key to use.

Example: File Configuration

cfg, err := ziti.NewConfigFromFile("client.json")
if err != nil {
    _, _ = fmt.Fprintf(os.Stderr, "failed to read configuration: %v", err)
    os.Exit(1)
}

Example: Code Configuration

// Note that GetControllerWellKnownCaPool() does not verify the authenticity of the controller, it is assumed
// this is handled in some other way.
caPool, err := ziti.GetControllerWellKnownCaPool("https://localhost:1280")

if err != nil {
    panic(err)
}

credentials := edge_apis.NewUpdbCredentials("Joe Admin", "20984hgn2q048ngq20-3gn")
credentials.CaPool = caPool

cfg := &ziti.Config{
    ZtAPI:       "https://localhost:1280/edge/client/v1",
    Credentials: credentials,
}
ctx, err := ziti.NewContext(cfg)

Create A Ziti Context

A Context instances represent a specific identity connected to a Ziti Controller. The instance, once configured, will handle authentication, re-authentication, posture state submission, and provides interfaces to dial/bind services.

context, err := ziti.NewContext(cfg)

if err != nil {
    _, _ = fmt.Fprintf(os.Stderr, "failed to create context: %v", err)
    os.Exit(1)
}

Dial/Bind A Service

The main activity performed with a Context is to dial or bind a service. In order for a dial or bind to be successful, the following must be true:

  1. The identity must have the proper dial or bind service policy to the service via Service Policies
  2. The identity must have the proper dial or bind services over at least one Edge Router via Edge Router Policies
  3. The service must be allowed to be dialed or bound on at least one Edge Router via Service Edge Router Policies)

The easiest way to satisfy #2 and #3 are the make use of the #all role attribute when creating the policies. Edge Router policies and Service Edge Router Policies are useful for geographic connection management. For smaller networks, test networks, and networks without geographic network entry are not concerns they add complexity without inherent benefit. Using the #all role attributes makes all service accessible and valid dial/bind targets on all Edge Routers.

Example: "All" Edge Router and Service Edge Router Policies

> ziti edge create service-edge-router-policy serp-all --edge-router-roles "#all" --service-roles "#all"
> ziti edge create edge-router-policy erp-all --edge-router-roles "#all" --identity-roles "#all"

Example: Dial and Bind Policies For a Service

> ziti edge create service-policy  testDial Dial --identity-roles "@myTestClient" --service-roles "@myChat"
> ziti edge create service-policy  testBind Bind --identity-roles "@myTestServer" --service-roles "@myChat"

Note: While policies can be created targeting specific users, services, or routers, using #attribute style assignments allows you to grant access based on groupings. (See Roles and Role Attributes)

Example: Dial

conn, err := context.Dial(serviceName)

if err != nil {
    _, _ = fmt.Fprintf(os.Stderr, "failed to dial service %v, err: %+v\n", serviceName, err)
    os.Exit(1)
}

if _, err := conn.Write([]byte("hello I am myTestClient")); err != nil {
    panic(err)
}

Example: Bind

Note: A full implementation will have to accept connections, hand them off to another goroutine and then re-wait on listener.Accept()

func main(){
    //... load configuration, create context
    
    listener, err := context.ListenWithOptions(serviceName, &options)
    if err != nil {
        logrus.Errorf("Error binding service %+v", err)
        panic(err)
    }
    
    for {
        conn, err := listener.Accept()
        if err != nil {
            logger.Errorf("server error, exiting: %+v\n", err)
            panic(err)
        }
        logger.Infof("new connection")
        go handleConn(conn)
    }
}

func handleConn(conn net.Conn){
    for {
        buf := make([]byte, 1024)
        n, err := conn.Read(buf)
        if err != nil {
            _ = conn.Close()
            return
        }
        stringData := string(buf[:n])
        println(stringData)
    }
}

Creating & Enrolling an Identity

For more detail on how to create and enroll identities see the identities section in the OpenZiti documentation.

  1. Login to the controller ziti edge login https://ctrl-api/edge/client/v1 -u <username> -p <password>
  2. Create a new identity ziti edge create identity device myTestClient -o client.enroll.jwt
  3. Enroll the identity ziti edge enroll client.enroll.jwt -o client.json

The output file, client.json in this file, is used as that target in the SDK call ziti.NewConfigFromFile("client.json") to create a configuration.

Allowing Dial/Bind Access to a Service

For more detail on policies see the policies section in the OpenZiti documentation.

  1. Login if not already logged in ziti edge login https://ctrl-api/edge/client/v1 -u <username> -p <password>
  2. Create a new service ziti edge create service myChat
  3. Allow the service to be accessed by the myTestClient through any Edge Router and the service myChat through any Edge Router
    1. ziti edge create service-policy testPolicy Dial --identity-roles "@myTestClient" --service-roles "@myChat"
    2. ziti edge create service-edge-router-policy chatOverAll --edge-router-roles "#all" --service-roles "@myChat"

Note: While policies can be created targeting specific users, services, or routers, using #attribute style assignments allows you to grant access based on groupings. (See Roles and Role Attributes)

Accessing the Management/Client API

The Edge Management and Client APIs are defined by an OpenAPI 2.0 specification and have a client that is generated and maintained in another GitHub repository. Accessing this repository directly should not be necessary. This SDK provides a wrapper around the generated clients found in edge-apis.

Example: Creating an Edge Management API Client

apiUrl, _ = url.Parse("https://localhost:1280/edge/management/v1") 

// Note that GetControllerWellKnownCaPool() does not verify the authenticity of the controller, it is assumed
// this is handled in some other way.
caPool, err := ziti.GetControllerWellKnownCaPool("https://localhost:1280")

if err != nil {
panic(err)
}

credentials := edge_apis.NewUpdbCredentials("Joe Admin", "20984hgn2q048ngq20-3gn")
credentials.CaPool = caPool

//Note: the CA pool can be provided here or during the Authenticate(<creds>) call. It is allowed here to enable
//      calls to REST API endpoints that do not require authentication.
managementClient := edge_apis.NewManagementApiClient(apiUrl, credentials.GetCaPool()),

//"configTypes" are string identifiers of configuration that can be requested by clients. Developers may
//specify their own in order to provide distributed identity and/or service specific configurations.
//
//See: https://openziti.io/docs/learn/core-concepts/config-store/overview
//Example: configTypes = []string{"myCustomAppConfigType"}
var configTypes []string

apiSesionDetial, err := managementClient.Authenticate(credentials, configTypes)

Example: Creating an Edge Client API Client

apiUrl, _ = url.Parse("https://localhost:1280/edge/client/v1") 

// Note that GetControllerWellKnownCaPool() does not verify the authenticity of the controller, it is assumed
// this is handled in some other way.
caPool, err := ziti.GetControllerWellKnownCaPool("https://localhost:1280")

if err != nil {
panic(err)
}

credentials := edge_apis.NewUpdbCredentials("Joe Admin", "20984hgn2q048ngq20-3gn")
credentials.CaPool = caPool

//Note: the CA pool can be provided here or during the Authenticate(<creds>) call. It is allowed here to enable
//      calls to REST API endpoints that do not require authentication.
client := edge_apis.NewClientApiClient(apiUrl, credentials.GetCaPool()),

//"configTypes" are string identifiers of configuration that can be requested by clients. Developers may
//specify their own in order to provide distributed identity and/or service specific configurations. The
//OpenZiti tunnelers use this capability to configure interception of network connections.
//See: https://openziti.io/docs/learn/core-concepts/config-store/overview
//Example: configTypes = []string{"myCustomAppConfigType"}
var configTypes []string

apiSesionDetial, err := client.Authenticate(credentials, configTypes)

Example: Requesting Management Services

The following example show how to list services. Altering the names of the package types used will allow the same code to work for the Edge Client API.

// GetServices retrieves services in chunks of 500 till it has accumulated all services.
func GetServices(client *apis.ManagementApiClient) ([]*rest_model.ServiceDetail, error) {
	params := service.NewListServicesParams()

	pageOffset := int64(0)
	pageLimit := int64(500)

	var services []*rest_model.ServiceDetail

	for {
		params.Limit = &pageLimit
		params.Offset = &pageOffset

		resp, err := client.API.Service.ListServices(params, nil)

		if err != nil {
			return nil, rest_util.WrapErr(err)
		}

		if services == nil {
			services = make([]*rest_model.ServiceDetail, 0, *resp.Payload.Meta.Pagination.TotalCount)
		}

		services = append(services, resp.Payload.Data...)

		pageOffset += pageLimit
		if pageOffset >= *resp.Payload.Meta.Pagination.TotalCount {
			break
		}
	}

	return services, nil
}

sdk-golang's People

Contributors

andrewpmartinez avatar camotts avatar dependabot-preview[bot] avatar dependabot[bot] avatar dovholuknf avatar ekoby avatar gberl002 avatar karlpokus avatar michaelquigley avatar mjtrangoni avatar plorenz avatar potto007 avatar qrkourier avatar r-caamano avatar rentallect avatar scareything avatar smilindave26 avatar tburtchell avatar ziti-ci avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sdk-golang's Issues

Go SDK Over Submits Posture Responses

If there are 4 MAC address-based posture checks it will submit 4 responses when only 1 is needed. This is true for all host static information (MAC, WIndows Domain, OS).

Ziti-Tunnel - Bind terminators are only created during startup

Ziti-Tunnel bind only creates terminators on startup

Description:
When you have a service bind on a ziti-tunnel, the terminators are only created once during startup. If the router that the bind is attached to is restarted, all the terminators on that router are removed. The terminators that were removed are not created again until the binding tunnel process is restarted.

To Replicate issue:

  1. Setup a bind service against a ziti-tunnel identity
  2. Start ziti-tunnel & make sure the terminators are created on edgeziti edge controller list terminators and fabric ziti-fabric list terminators
  3. Restart the ziti-router(s) that have terminators.
  4. List the terminators again & see they are never recreated until the bind tunnel process is restarted.

Environment:

OS: Centos 7.8
Ziti Version: 14.2

EC keys error when dialing

steps to reproduce:

  • enroll an identity with the C sdk - verify an EC PRIVATE KEY is generated
  • attempt to use this enrolled .json with the golang sdk by calling DialWithOptions

observe:

  • no connection is made
  • error is returned which is not particularly helpful

failed to initialize context: (open -----BEGIN EC PRIVATE KEY-----\n ... snip ... YK/s9cIJYnYg==\n-----END EC PRIVATE KEY-----\n: The filename, directory name, or volume label syntax is incorrect.)"

service binding needs to restart if service is recreated

Probably not a scenario that happens in production but during development this is something I do routinely. Seems like it might be a bug

  • make a config for tunneller to dial a service by identity"
  • make a service using the config from above
  • create 2 service policies - one for an identity to dial the service, one for an identity to host the service
  • start a golang program which binds the service
  • make a request via the tunneller - see it 'work'...
  • delete the service and the config
  • recreate the service and the config (without restarting the golang program)

Observe this over and over:

time="2022-03-28T22:50:10Z" level=warning msg="failure creating Bind session to service my.svc" error="unable to find resource. http status code: 404, msg: {\"error\":{\"cause\":{\"code\":\"UNHANDLED\",\"message\":\"service with id FsKqVJu6H not found\"},\"code\":\"NOT_FOUND\",\"message\":\"The resource requested was not found or is no longer available\",\"requestId\":\"J.8mVLu8y\"},\"meta\":{\"apiEnrollmentVersion\":\"0.0.1\",\"apiVersion\":\"0.0.1\"}}\n"

service never rebinds.... restart the process and things work as expected

multiple content types in response from controller will lose enrollment result

When using the latest enroller against an some older controller versions multip content types will be returned in the response. if the first content type is application/json this will trigger a bug and cause the enroller to error. In the process the 'successful' enrollment will be lost.

Update the enroller to deal with this situation and "worst case" use the response as the pem file printing a warning that > 1 content type was detected.

Ziti-Probe - New edge-routers are not detected

Ziti-Probe doesn't get updated list of routers without restarting

Description:
When a probe is running, it never starts to probe the new routers until the process is restarted.

To Replicate issue:

  1. Setup probe network
  2. Start probe client
  3. Add a new edge-router to the network and verify connectivity with edge ziti edge controller list edge-routers -j and fabric ziti-fabric list routers
  4. Query the data to see the new edge router never appears in the data curl -G 'http://localhost:8086/query?pretty=true' --data-urlencode "db=ziti" --data-urlencode "q=SHOW MEASUREMENTS"

Once you restart the process the data is gathered and inserted into the DB.

Environment:

OS: Centos 7.8
Ziti Version: 14.2

SDK fails to compile for a raspberry pi with "undefined: pkcs11.Ctx"

I'm trying to build a server to run on an arm device (Raspberry Pi), and the build is failing with the following:

GOOS=linux GOARCH=arm go build -tags legacy -ldflags "-w -s -X 'main.Version=' -X 'main.Branch=git rev-parse --abbrev-ref HEAD`'" -o deb/ptzcam-mock/opt/lvt/bin/ptzcam-mock;

github.com/openziti/identity/engines/pkcs11

../../../../../go/pkg/mod/github.com/openziti/[email protected]/engines/pkcs11/engine.go:50:35: undefined: pkcs11.Ctx
../../../../../go/pkg/mod/github.com/openziti/[email protected]/engines/pkcs11/engine.go:55:16: undefined: pkcs11.Ctx
../../../../../go/pkg/mod/github.com/openziti/[email protected]/engines/pkcs11/engine.go:56:15: undefined: pkcs11.SessionHandle
../../../../../go/pkg/mod/github.com/openziti/[email protected]/engines/pkcs11/engine.go:57:15: undefined: pkcs11.ObjectHandle
../../../../../go/pkg/mod/github.com/openziti/[email protected]/engines/pkcs11/engine.go:58:16: undefined: pkcs11.Mechanism
../../../../../go/pkg/mod/github.com/openziti/[email protected]/engines/pkcs11/engine.go:268:41: undefined: pkcs11.Ctx
../../../../../go/pkg/mod/github.com/openziti/[email protected]/engines/pkcs11/engine.go:290:36: undefined: pkcs11.Ctx
../../../../../go/pkg/mod/github.com/openziti/[email protected]/engines/pkcs11/engine.go:290:86: undefined: pkcs11.Mechanism
../../../../../go/pkg/mod/github.com/openziti/[email protected]/engines/pkcs11/engine.go:327:31: undefined: pkcs11.Ctx
../../../../../go/pkg/mod/github.com/openziti/[email protected]/engines/pkcs11/engine.go:327:51: undefined: pkcs11.SessionHandle
../../../../../go/pkg/mod/github.com/openziti/[email protected]/engines/pkcs11/engine.go:327:51: too many errors`

Any idea what I need to do?

auto-enroll example Reflect client / server

I like the Go Reflect example client and server as a reference implementation for Go SDK. We should demonstrate how to handle the enrollment token as a file, env var, or stdin, or some combination of the three, for the instructive value.

In lieu of an enrollment example it's predictable that many people will need to, or at least be tempted to, orchestrate the ziti CLI to perform enrollment for their Zitified apps.

examples/zping-client exhibits unexpected behavior when greater than 9 pings are sent.

if sequence # is greater than 9 incorrect number of bytes sent for each ping due to incorrect subtraction of sequence length. Need to remove "var count" and replace with psession.psent when calculating length of random string data

ex.

Sending 100 byte pings to server01:

100 bytes from server01: ziti_seq=1 time=78.602ms
100 bytes from server01: ziti_seq=2 time=78.964ms
100 bytes from server01: ziti_seq=3 time=78.475ms
100 bytes from server01: ziti_seq=4 time=78.395ms
100 bytes from server01: ziti_seq=5 time=78.849ms
100 bytes from server01: ziti_seq=6 time=78.781ms
100 bytes from server01: ziti_seq=7 time=78.918ms
100 bytes from server01: ziti_seq=8 time=78.859ms
100 bytes from server01: ziti_seq=9 time=79.021ms
101 bytes from server01: ziti_seq=10 time=79.750ms

Don't use hostname for CN in CSR

ziti/enroll/enroll.go uses hostname for CN in CSR used during enrollment. Hostnames can contain underscores. This is a problem because the golang asn1 parser does not support underscores in printablestring fields of asn1 structures (like CSRs). Upshot is that attempts to enroll from hosts that have a name containing an underscore will fail.

Session IDs and Tokens should be presented and labeled consistently

In various log messages, the values for edge-session ids, api-session-ids, and their associated tokens are presented with labels of "token" and "session_id". These can be confusing when reading logs, moving back and forth between them. There is at least one "ns" label.

Jun 28 12:58:28 netfoundry-vm ziti-tunnel[845]: {"file":"/home/runner/go/pkg/mod/github.com/openziti/[email protected]/ziti/ziti.go:664","func":"github.com/openziti/sdk-golang/ziti.(contextImpl).getEdgeRouterConn","level":"debug","msg":"selected router[HO-Dubai-Edge@tls://192.168.0.210:443] for best latency(0 ms)","ns":"39b0735d-0efa-416f-a995-7c493e495056",***"time":"2021-06-28T12:58:28Z"}

Jun 28 12:58:30 netfoundry-vm ziti-tunnel[845]: {"file":"/home/runner/go/pkg/mod/github.com/openziti/[email protected]/ziti/ziti.go:537","func":"github.com/openziti/sdk-golang/ziti.(*contextImpl).DialWithOptions","level":"debug","msg":"connecting via **session id [ckqgmegok1eigic80jooh3wj2] token [39b0735d-0efa-416f-a995-7c493e495056]"**,"time":"2021-06-28T12:58:30Z"}

enable api-sessions from jwt

right now there is no convinient way to use an external jwt signer for authentication of api sessions in the golang sdk.

provide a way to use a jwt to create an api session and subsequently sessions as easily as we can with identity files/3rd party ca/etc

CA bundle isn't always fetched during enrollment

see discourse for more details https://openziti.discourse.group/t/ziti-edge-enrol-identity-not-inserting-ca-bundle/814/30

It seems that if you have a PKI for the edge controller API, and a DIFFERENT PKI for the edge data plane, the enrollment of an identity will succeed but the logic that determines if the ca bundle needs to be pulled down will not trigger, and then when the identity tries to connect it will not be able to successfully connect to the routers.

code is at https://github.com/openziti/sdk-golang/blob/main/ziti/enroll/enroll.go#L232-L258

Error while compiling with sdk - undefined pkcs11.Ctx

I am trying to integrate ziti sdk into my http client code. Getting the following error when compiling it with the latest ziti sdk

CGO_ENABLED=0 go build -ldflags "-X main.Branch= -X main.Revision=c3ec49a -X main.Version= -extldflags \"-static\" -s -w" -tags netgo -o cmd/app-informer/app-informer ./cmd/app-informer
# github.com/openziti/foundation/identity/engines/pkcs11
/go/pkg/mod/github.com/openziti/[email protected]/identity/engines/pkcs11/engine.go:55:9: undefined: pkcs11.Ctx
/go/pkg/mod/github.com/openziti/[email protected]/identity/engines/pkcs11/engine.go:56:8: undefined: pkcs11.SessionHandle
/go/pkg/mod/github.com/openziti/[email protected]/identity/engines/pkcs11/engine.go:57:8: undefined: pkcs11.ObjectHandle
/go/pkg/mod/github.com/openziti/[email protected]/identity/engines/pkcs11/engine.go:58:9: undefined: pkcs11.Mechanism
/go/pkg/mod/github.com/openziti/[email protected]/identity/engines/pkcs11/engine.go:268:34: undefined: pkcs11.Ctx
/go/pkg/mod/github.com/openziti/[email protected]/identity/engines/pkcs11/engine.go:290:29: undefined: pkcs11.Ctx
/go/pkg/mod/github.com/openziti/[email protected]/identity/engines/pkcs11/engine.go:290:79: undefined: pkcs11.Mechanism
/go/pkg/mod/github.com/openziti/[email protected]/identity/engines/pkcs11/engine.go:327:24: undefined: pkcs11.Ctx
/go/pkg/mod/github.com/openziti/[email protected]/identity/engines/pkcs11/engine.go:327:44: undefined: pkcs11.SessionHandle
/go/pkg/mod/github.com/openziti/[email protected]/identity/engines/pkcs11/engine.go:327:69: undefined: pkcs11.ObjectHandle
/go/pkg/mod/github.com/openziti/[email protected]/identity/engines/pkcs11/engine.go:327:69: too many errors
make: *** [Makefile:115: cmd/app-informer/app-informer] Error 2
make: Leaving directory '/go/src/github.com/in2tivetech/ozone'
Command exited with non-zero status 2
0.26user 0.13system 3:30.46elapsed 0%CPU (0avgtext+0avgdata 59508maxresident)k
0inputs+0outputs (0major+7706minor)pagefaults 0swaps
make: *** [Makefile:108: cmd/app-informer/app-informer] Error 2

Log enhancement for connections

Is there context for this, such as Connection iD?

Jun 28 12:58:28 netfoundry-vm ziti-tunnel[845]: {"file":"/home/runner/go/pkg/mod/github.com/openziti/[email protected]/ziti/ziti.go:664","func":"github.com/openziti/sdk-golang/ziti.(*contextImpl).getEdgeRouterConn","level":"debug","msg":"selected router[HO-Dubai-Edge@tls://192.168.0.210:443] for best latency(0 ms)","ns":"39b0735d-0efa-416f-a995-7c493e495056","time":"2021-06-28T12:58:28Z"}

Is this the follow on message and is it possible to determine what selection event it relevant to?
Jun 28 12:58:30 netfoundry-vm ziti-tunnel[845]: {"file":"/home/runner/go/pkg/mod/github.com/openziti/[email protected]/ziti/ziti.go:537","func":"github.com/openziti/sdk-golang/ziti.(*contextImpl).DialWithOptions","level":"debug","msg":"connecting via session id [ckqgmegok1eigic80jooh3wj2] token [39b0735d-0efa-416f-a995-7c493e495056]","time":"2021-06-28T12:58:30Z"}

Is this the follow on failure and is it possible to determine what connection request it is relevant to?
Jun 28 12:58:31 netfoundry-vm ziti-tunnel[845]: {"connId":43,"file":"/home/runner/go/pkg/mod/github.com/openziti/[email protected]/ziti/edge/impl/conn.go:191","func":"github.com/openziti/sdk-golang/ziti/edge/impl.(*edgeConn).Connect","level":"error","msg":"timeout waiting for response","time":"2021-06-28T12:58:31Z"}

sdk-golang v0.20.49 loops forever with older 'ws://' edge router

the latest golang sdk ends up erroring in a loop forever if it's used on a network with a ws:// router... :

ERRO[0004] failed to parse url[ws://ziti-edge-router-wss:3023]  error="address (ws://ziti-edge-router-wss:3023) not parsed"
ERRO[0039] failed to parse url[ws://ziti-edge-router-wss:3023]  error="address (ws://ziti-edge-router-wss:3023) not parsed"
ERRO[0041] failed to parse url[ws://ziti-edge-router-wss:3023]  error="address (ws://ziti-edge-router-wss:3023) not parsed"
ERRO[0041] failed to parse url[ws://ziti-edge-router-wss:3023]  error="address (ws://ziti-edge-router-wss:3023) not parsed"
ERRO[0041] failed to parse url[ws://ziti-edge-router-wss:3023]  error="address (ws://ziti-edge-router-wss:3023) not parsed"

steps to reproduce

Dependabot can't resolve your Go dependency files

Dependabot can't resolve your Go dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

dmitri.shuralyov.com/app/[email protected]: unrecognized import path "dmitri.shuralyov.com/app/changes" (https fetch: Get https://dmitri.shuralyov.com/app/changes?go-get=1: EOF)

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

ziti.LoadContext(path) not idempotent - crashes when called twice

Observed:
Panic when calling ctx, err = ziti.LoadContext(idFile) twice

Expected:
I didn't know what I expected, but I think it probably makes sense for this to be idempotent -- or at very least it should not panic

Stack

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0x70b2a5]

goroutine 1 [running]:
github.com/openziti/sdk-golang/ziti/edge/api.(*lazyClient).Shutdown(0xc000458680)
        <autogenerated>:1 +0x25
github.com/openziti/sdk-golang/ziti.(*contextImpl).Close(0xc00023e3c0)
        C:/Users/clint/go/pkg/mod/github.com/openziti/[email protected]/ziti/ziti.go:1077 +0x32a
github.com/openziti/sdk-golang/ziti.LoadContext({0xc00003d9c0, 0x23})
        C:/Users/clint/go/pkg/mod/github.com/openziti/[email protected]/ziti/contexts.go:59 +0x3fd
github.com/edgexfoundry/edgex-ui-go/internal.initClientsMapping(0xc000228c00)
        V:/work/git/github/external/edgex/edgex-ui-go/internal/application.go:65 +0x285

Dependabot can't resolve your Go dependency files

Dependabot can't resolve your Go dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

sourcegraph.com/sourcegraph/[email protected]: unrecognized import path "sourcegraph.com/sourcegraph/go-diff" (parse https://sourcegraph.com/sourcegraph/go-diff?go-get=1: no go-import meta tags ())

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

example Reflect Server fails to load if identity file is symbolic link

Kubernetes secrets are often symbolic links because of the way that files are "projected" into a configurable file path. This caused me to discover the Reflect server can't run in Kubernetes because it treats symlinks as a file not found.

# I modified the Dockerfile to run `ls -lA /identity/` which is the dir where the identity is mounted, and here we can see the symlink
reflect-server_1  | lrwxrwxrwx 1 appuser appgroup   49 Aug 11 21:23 KenReflectSrv1.json -> /home/kbingham/.ziti-edge-tunnel/Reflect1748.json
# reflect server --verbose --identity=/identity/KenReflectSrv1.json --serviceName="${SERVICE_NAME}"
reflect-server_1  | FATAL   failed to load ziti configuration file: config file (/identity/KenReflectSrv1.json) is not found  

Do not call os.Exit

The Go SDK has a few cases where it will cause the hosting process to exit.

  • Remove them
  • Deal with situations where API sessions can be reused

Enrollment Check For Private Key Encryption

When enrolling if a private key is supplied that has password protection, it is blindly used and the user receives an ANS1 error.

Example Where test.key is password protected:

ziti-tunnel enroll -j test.jwt -o test.json -k test.key -c test.pem
ERROR   error: failed to enroll: asn1: structure error: length too large

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.