Skip to content

Commit 8ae5174

Browse files
authored
feat(connect): add --server-name flag for tunneled connections (#678)
Co-authored-by: Jimmy Stridh <jimmystridh@users.noreply.github.com>
1 parent 2138fa7 commit 8ae5174

File tree

18 files changed

+335
-47
lines changed

18 files changed

+335
-47
lines changed

cmd/sqlcmd/sqlcmd.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ type SQLCmdArguments struct {
8282
ChangePassword string
8383
ChangePasswordAndExit string
8484
TraceFile string
85+
ServerNameOverride string
8586
// Keep Help at the end of the list
8687
Help bool
8788
}
@@ -411,6 +412,7 @@ func setFlags(rootCmd *cobra.Command, args *SQLCmdArguments) {
411412
rootCmd.Flags().StringVarP(&args.InitialQuery, "initial-query", "q", "", localizer.Sprintf("Executes a query when sqlcmd starts, but does not exit sqlcmd when the query has finished running. Multiple-semicolon-delimited queries can be executed"))
412413
rootCmd.Flags().StringVarP(&args.Query, "query", "Q", "", localizer.Sprintf("Executes a query when sqlcmd starts and then immediately exits sqlcmd. Multiple-semicolon-delimited queries can be executed"))
413414
rootCmd.Flags().StringVarP(&args.Server, "server", "S", "", localizer.Sprintf("%s Specifies the instance of SQL Server to which to connect. It sets the sqlcmd scripting variable %s.", localizer.ConnStrPattern, localizer.ServerEnvVar))
415+
rootCmd.Flags().StringVar(&args.ServerNameOverride, "server-name", "", localizer.Sprintf("Specifies the server name to use for authentication when tunneling through a proxy. Use with -S to specify the dial address separately from the server name sent to SQL Server."))
414416
_ = rootCmd.Flags().IntP(disableCmdAndWarn, "X", 0, localizer.Sprintf("%s Disables commands that might compromise system security. Passing 1 tells sqlcmd to exit when disabled commands are run.", "-X[1]"))
415417
rootCmd.Flags().StringVar(&args.AuthenticationMethod, "authentication-method", "", localizer.Sprintf(
416418
"Specifies the SQL authentication method to use to connect to Azure SQL Database. One of: %s",
@@ -738,6 +740,7 @@ func setConnect(connect *sqlcmd.ConnectSettings, args *SQLCmdArguments, vars *sq
738740
}
739741
connect.HostNameInCertificate = args.HostNameInCertificate
740742
connect.ServerCertificate = args.ServerCertificate
743+
connect.ServerNameOverride = args.ServerNameOverride
741744
connect.PacketSize = args.PacketSize
742745
connect.WorkstationName = args.WorkstationName
743746
connect.LogLevel = args.DriverLoggingLevel

internal/translations/catalog.go

Lines changed: 51 additions & 46 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/translations/locales/de-DE/out.gotext.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2672,6 +2672,11 @@
26722672
],
26732673
"fuzzy": true
26742674
},
2675+
{
2676+
"id": "Specifies the server name to use for authentication when tunneling through a proxy. Use with -S to specify the dial address separately from the server name sent to SQL Server.",
2677+
"message": "Specifies the server name to use for authentication when tunneling through a proxy. Use with -S to specify the dial address separately from the server name sent to SQL Server.",
2678+
"translation": ""
2679+
},
26752680
{
26762681
"id": "{_X1} Disables commands that might compromise system security. Passing 1 tells sqlcmd to exit when disabled commands are run.",
26772682
"message": "{_X1} Disables commands that might compromise system security. Passing 1 tells sqlcmd to exit when disabled commands are run.",
@@ -3671,6 +3676,11 @@
36713676
],
36723677
"fuzzy": true
36733678
},
3679+
{
3680+
"id": "Server name override is not supported with the current authentication method",
3681+
"message": "Server name override is not supported with the current authentication method",
3682+
"translation": ""
3683+
},
36743684
{
36753685
"id": "Password:",
36763686
"message": "Password:",

internal/translations/locales/en-US/out.gotext.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2674,6 +2674,13 @@
26742674
],
26752675
"fuzzy": true
26762676
},
2677+
{
2678+
"id": "Specifies the server name to use for authentication when tunneling through a proxy. Use with -S to specify the dial address separately from the server name sent to SQL Server.",
2679+
"message": "Specifies the server name to use for authentication when tunneling through a proxy. Use with -S to specify the dial address separately from the server name sent to SQL Server.",
2680+
"translation": "Specifies the server name to use for authentication when tunneling through a proxy. Use with -S to specify the dial address separately from the server name sent to SQL Server.",
2681+
"translatorComment": "Copied from source.",
2682+
"fuzzy": true
2683+
},
26772684
{
26782685
"id": "{_X1} Disables commands that might compromise system security. Passing 1 tells sqlcmd to exit when disabled commands are run.",
26792686
"message": "{_X1} Disables commands that might compromise system security. Passing 1 tells sqlcmd to exit when disabled commands are run.",
@@ -3675,6 +3682,13 @@
36753682
],
36763683
"fuzzy": true
36773684
},
3685+
{
3686+
"id": "Server name override is not supported with the current authentication method",
3687+
"message": "Server name override is not supported with the current authentication method",
3688+
"translation": "Server name override is not supported with the current authentication method",
3689+
"translatorComment": "Copied from source.",
3690+
"fuzzy": true
3691+
},
36783692
{
36793693
"id": "Password:",
36803694
"message": "Password:",

0 commit comments

Comments
 (0)