forked from apernet/hysteria
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'apernet:master' into master
- Loading branch information
Showing
21 changed files
with
533 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/apernet/hysteria/app/v2/internal/utils" | ||
"github.com/spf13/cobra" | ||
"github.com/spf13/viper" | ||
"go.uber.org/zap" | ||
) | ||
|
||
var ( | ||
noText bool | ||
withQR bool | ||
) | ||
|
||
// shareCmd represents the share command | ||
var shareCmd = &cobra.Command{ | ||
Use: "share", | ||
Short: "Generate share URI", | ||
Long: "Generate a hysteria2:// URI from a client config for sharing", | ||
Run: runShare, | ||
} | ||
|
||
func init() { | ||
initShareFlags() | ||
rootCmd.AddCommand(shareCmd) | ||
} | ||
|
||
func initShareFlags() { | ||
shareCmd.Flags().BoolVar(&noText, "notext", false, "do not show URI as text") | ||
shareCmd.Flags().BoolVar(&withQR, "qr", false, "show URI as QR code") | ||
} | ||
|
||
func runShare(cmd *cobra.Command, args []string) { | ||
if err := viper.ReadInConfig(); err != nil { | ||
logger.Fatal("failed to read client config", zap.Error(err)) | ||
} | ||
var config clientConfig | ||
if err := viper.Unmarshal(&config); err != nil { | ||
logger.Fatal("failed to parse client config", zap.Error(err)) | ||
} | ||
if _, err := config.Config(); err != nil { | ||
logger.Fatal("failed to load client config", zap.Error(err)) | ||
} | ||
|
||
u := config.URI() | ||
|
||
if !noText { | ||
fmt.Println(u) | ||
} | ||
if withQR { | ||
utils.PrintQR(u) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 73 additions & 1 deletion
74
core/internal/integration_tests/mocks/mock_TrafficLogger.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.