-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feat(client): add usage reporting #2369
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
...c/cordova/android/OutlineAndroidLib/outline/src/main/aidl/org/outline/IVpnTunnelService.aidl
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution! As discussed in the meeting, please:
- Refactor the
newTunnel
to accept aClient
parameter - Parse the reporting config in
NewClientWithBaseDialers
, we can add new reporting field totype Client struct
- Start the reporting here or here by reading the parsed reporting config field in
Client
. Maybe the latter one is better because we will add "Stop reporting" logic in the same file, but this means we need to pass additional reporting config parameter toTunnel
, this is a trade-off. - Stop the reporting here
Please also fix the go tests, the CI seems to be failing.
...nt/src/cordova/android/OutlineAndroidLib/outline/src/main/aidl/org/outline/TunnelConfig.aidl
Outdated
Show resolved
Hide resolved
...ordova/android/OutlineAndroidLib/outline/src/main/java/org/outline/vpn/VpnTunnelService.java
Outdated
Show resolved
Hide resolved
client/src/cordova/plugin/android/java/org/outline/OutlinePlugin.java
Outdated
Show resolved
Hide resolved
…om the // Android plugin.
…into usage-reporting-v2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PTAL
client/src/cordova/plugin/android/java/org/outline/OutlinePlugin.java
Outdated
Show resolved
Hide resolved
...nt/src/cordova/android/OutlineAndroidLib/outline/src/main/aidl/org/outline/TunnelConfig.aidl
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the update! The code looks a lot better.
@@ -7,7 +7,7 @@ | |||
// http://www.apache.org/licenses/LICENSE-2.0 | |||
// | |||
// Unless required by applicable law or agreed to in writing, software | |||
// distributed under the License is distributed on an "AS IS" BASIS, | |||
// distributed under the License is distributed on an "AS IS BASIS, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Plz revert
// distributed under the License is distributed on an "AS IS BASIS, | |
// distributed under the License is distributed on an "AS IS" BASIS, |
client/go/outline/client.go
Outdated
if err != nil { | ||
return nil, &platerrors.PlatformError{ | ||
Code: platerrors.InvalidConfig, | ||
Message: "config is not valid YAML", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make the error message different from the previous one so the user knows what's going wrong.
Message: "config is not valid YAML", | |
Message: "client config is not valid YAML", |
client/go/outline/client.go
Outdated
if errors.Is(err, errors.ErrUnsupported) { | ||
return nil, &platerrors.PlatformError{ | ||
Code: platerrors.InvalidConfig, | ||
Message: "unsupported config", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
Message: "unsupported config", | |
Message: "unsupported client config", |
@@ -101,5 +126,31 @@ func NewClientWithBaseDialers(transportConfig string, tcpDialer transport.Stream | |||
} | |||
} | |||
|
|||
return &Client{sd: transportPair.StreamDialer, pl: transportPair.PacketListener}, nil | |||
usageReportYAML, err := config.ParseConfigYAML(sessionConfig) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this sessionConfig
specific to sessionReportingConfig
? Or can it be used for other types of sessionConfig
in the future? If it's the latter, we should probably implement type assertion to ensure the type is 'reporting'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the easiest is to move the parsing of the clientConfig to the config module, which already takes care of this. And it allows you to use first_supported
} | ||
} | ||
} | ||
fmt.Println("usageReporter", usageReporter) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this for debugging purpose or logging purpose?
Name: cookieParts[0], | ||
Value: cookieParts[1], | ||
}) | ||
fmt.Println("Cookie found:", cookie) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logging/debugging?
func loadCookies(jar http.CookieJar, filename string) ([]*url.URL, error) { | ||
// Read cookies from the file | ||
file, err := os.Open(filename) | ||
if os.IsNotExist(err) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | ||
|
||
// Save the cookies data to a file | ||
file, err := os.Create(filename) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we discussed for privacy, do we need to allow the user to delete this cookie file (though removing the key or any other methods)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | ||
case <-ctx.Done(): | ||
// Stop reporting when the context is canceled | ||
fmt.Println("Stopping reporting...") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
debugging?
case <-ticker.C: | ||
err := Report(tcp, ur.Url) | ||
if err != nil { | ||
fmt.Printf("Report failed: %v\n", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Plz use slog
for logging?
|
||
// Stop reporting on the Client instance | ||
if (this.outlineClient != null) { | ||
this.outlineClient.stopReporting(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move to tearDownActiveTunnel. But I wonder if we should just implement that in stopRemoteDevice instead and revert this file. Why would we not align them?
client/go/outline/client.go
Outdated
@@ -41,6 +45,10 @@ func (c *Client) ListenPacket(ctx context.Context) (net.PacketConn, error) { | |||
return c.pl.ListenPacket(ctx) | |||
} | |||
|
|||
func (c *Client) GetUsageReporter() *config.UsageReporter { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed? You already provide Start/StopReporting. Remove?
client/go/outline/client.go
Outdated
// NewClient creates a new Outline client from a configuration string. | ||
func NewClient(transportConfig string) *NewClientResult { | ||
func NewClient(transportConfig string, sessionConfig string) *NewClientResult { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a session config. It's a report config. But we should merge them into a client config.
client/go/outline/client.go
Outdated
if err != nil { | ||
return &NewClientResult{Error: platerrors.ToPlatformError(err)} | ||
} | ||
return &NewClientResult{Client: client} | ||
} | ||
|
||
func NewClientWithBaseDialers(transportConfig string, tcpDialer transport.StreamDialer, udpDialer transport.PacketDialer) (*Client, error) { | ||
func NewClientWithBaseDialers(transportConfig string, sessionConfig string, tcpDialer transport.StreamDialer, udpDialer transport.PacketDialer) (*Client, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same
@@ -101,5 +126,31 @@ func NewClientWithBaseDialers(transportConfig string, tcpDialer transport.Stream | |||
} | |||
} | |||
|
|||
return &Client{sd: transportPair.StreamDialer, pl: transportPair.PacketListener}, nil | |||
usageReportYAML, err := config.ParseConfigYAML(sessionConfig) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the easiest is to move the parsing of the clientConfig to the config module, which already takes care of this. And it allows you to use first_supported
transport: string; | ||
session_report: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
transport: string; | |
session_report: string; | |
client: string; |
defer conn.Close() | ||
|
||
// Create an HTTP POST request with cookies and a sample body | ||
requestBody := "param1=value1¶m2=value2" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use the http.Client instead of rolling out your own.
} | ||
|
||
// StartReporting calls the Report function at every internal. | ||
func StartReporting(ctx context.Context, tcp transport.StreamDialer, ur *config.UsageReporter) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cookies must be siloed across access keys. You must take into account the service id somehow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Current, cookies for all keys belonging to a provider are sent in the request. The provider should be able to dedupe them. Can you explain the requirement that motivates separating these cookies per key?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Each access key must have their own separate cookie jar to prevent possible cross-service leaks. It's a security requirement. Imagine two separate services talking to the same reporting service, for example.
Also, you need to delete the cookies when you delete the key, and this makes it easier, because you don't know the domains it needs to talk to.
Please pull the latest master |
No description provided.