Dev Tunnels

repository·main·Indexed 19 days ago

https://github.com/microsoft/dev-tunnels

A service and set of SDKs (Java, Go, Rust, TypeScript/Node.js) that allow developers to securely expose local web services to the internet for remote debugging and testing of web applications and webhooks. It includes a CLI, integration with Visual Studio 2022, and a Node.js contracts library for managing tunnel connections.

Tokens
14.7K
Snippets
53
Records
69
Agent score
67%

What's inside dev-tunnels

  1. Overview of Dev tunnels

    main
    Dev tunnels allow developers to securely expose local web services to the internet. This enables you to control access permissions and easily debug web applications from any location. The service is integrated into various developer workflows, including the devtunnel CLI and Visual Studio 2022.
  2. Overview of the Visual Studio Tunnels Contracts Library

    main
    The Visual Studio Tunnels Contracts Library is a Node.js library designed to provide the necessary contracts and interfaces for managing Dev Tunnels connections. It serves as the foundational layer for implementing tunnel connection logic within Node.js environments.
  3. Overview of Visual Studio Tunnels Contracts Library

    main
    The Visual Studio Tunnels Contracts Library is a Node.js library providing the necessary contracts and interfaces for working with Dev Tunnels. It serves as the foundational layer for defining how tunnel operations, connections, and management interactions are structured within the Node.js ecosystem.
  4. How to file issues and get help

    main

    To report bugs or request new features, use the GitHub Issues tracker. Before filing a new issue, search existing issues to ensure your topic has not already been addressed.

    For general questions or help regarding the use of Dev Tunnels, contact the team via email.

  5. Run tests for the Tunnels Java SDK

    main

    Before running tests, you must configure the environment with a valid user token and tunnel name.

    Environment Variables

    VariableDescription
    TEST_TUNNEL_TOKENSet to Bearer <token> (get the token via CLI)
    TEST_TUNNEL_NAMEThe name of the tunnel to use
    TEST_TUNNEL_VERBOSE(Optional) Set to 1 to enable verbose console logging

    Steps to Test

    1. Get a token: Run the CLI command user show --verbose to retrieve a user token.
    2. Configure variables: Set TEST_TUNNEL_TOKEN using the format Bearer <token> and set TEST_TUNNEL_NAME.
    3. Host the tunnel: Use the CLI to host the tunnel.
    4. Execute tests: Run all tests with mvn test or a specific test case using the -Dtest flag.
    mvn test -Dtest=TunnelClientTests#connectClient
  6. Set up the Tunnels Java SDK development environment

    main

    To develop the Tunnels Java SDK, use VS Code with the following configuration:

    1. Clone the repository and open the java folder in VS Code.
    2. Install the Extension Pack for Java.
    3. Install JDK version 11 (LTS) when prompted.
    4. Install Maven. Ensure M2_HOME and other necessary environment variables are configured.
    5. Run mvn test to verify the setup.
    mvn test
  7. Set up the Go Getting Started example

    main

    To run the getting_started.go example, you must first provision a tunnel and configure the local environment with the necessary identifiers and credentials. Follow these steps:

    1. Provision a Tunnel: Create a tunnel using the CLI or another SDK. Obtain the tunnelId and clusterId from the created tunnel.
    2. Configure Identifiers: Open example.go and place the tunnelId and clusterId into the constants section.
    3. Configure Ports: Create the specific ports on your tunnel that you intend to host.
    4. Set Authentication: Obtain a tunnels access token. You can provide this in one of two ways:
      • Hardcode it by updating the return value of the getAccessToken() function in example.go.
      • Set it as an environment variable named TUNNELS_TOKEN.
    5. Start the Tunnel: Ensure the tunnel is actively hosting (via CLI or another SDK).
    6. Execute: Run the example using the Go CLI.
    go run example.go
  8. Update dependencies when making changes to the SDK

    main

    When updating the SDK, you must ensure that the package.json files in the connections and management packages require a dependency version strictly greater than the currently published version.

    To find the current published version, use: npm view @microsoft/dev-tunnels-contracts

    This prevents dependency mismatches caused by package managers like yarn pulling older versions of packages.

    npm view @microsoft/dev-tunnels-contracts
  9. Publish a new version of the Go tunnels package

    main

    To release a new version of the Go tunnels package, follow these steps to update the version constant, tag the release in Git, and publish it to the Go package index:

    1. Update the packageVersion constant in tunnels.go to the new version number.
    2. Create a Git tag for the new version using git tag v0.0.X (replace X with your version number).
    3. Push the tag to GitHub using git push origin v0.0.X.
    4. Publish the version to the Go package index by running go list -m github.com/microsoft/dev-tunnels@v0.0.X.
    # 1. Update packageVersion in tunnels.go
    # 2. Tag the version
    git tag v0.0.X
    
    # 3. Push the tag
    git push origin v0.0.X
    
    # 4. Publish to Go package index
    go list -m github.com/microsoft/dev-tunnels@v0.0.X
  10. Publish a new version of the Tunnels Java SDK

    main

    The Java SDK is published to GitHub Packages using a specific tagging convention. Java packages are identified by tags in the format java-vX.Y.Z.

    To publish a new version:

    1. Create a new GitHub release.
    2. Create a tag using the java-vX.Y.Z format (e.g., java-v0.1.27). The version must be higher than the current latest java-* tag.
    3. Set the release title to match the version tag.
    4. Publish the release.