From 051ab4a43628d77e610d088700b7090eb2141c39 Mon Sep 17 00:00:00 2001 From: DecFox <33030671+DecFox@users.noreply.github.com> Date: Thu, 21 Nov 2024 13:19:34 +0530 Subject: [PATCH] refactor(oonimkall): expose the session close call (#1657) ## Checklist - [x] I have read the [contribution guidelines](https://github.com/ooni/probe-cli/blob/master/CONTRIBUTING.md) - [x] reference issue for this pull request: https://github.com/ooni/probe/issues/2810 - [ ] if you changed anything related to how experiments work and you need to reflect these changes in the ooni/spec repository, please link to the related ooni/spec pull request: - [ ] if you changed code inside an experiment, make sure you bump its version number ## Description This diff exposes the `Session.Close` call for the geoip session we initialize in the mobile app. This is required to close the circumvention tunnel before we use start another tunnel as part of the async tasks to run the experiments. --- pkg/oonimkall/session.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/oonimkall/session.go b/pkg/oonimkall/session.go index 9933208348..f557aeb94e 100644 --- a/pkg/oonimkall/session.go +++ b/pkg/oonimkall/session.go @@ -254,6 +254,13 @@ func (sess *Session) NewContextWithTimeout(timeout int64) *Context { return &Context{cancel: cancel, ctx: ctx} } +// Close closes the session. This is done by closing the embedded engine +// session and ensures that any tunnel (if open) is stopped +func (sess *Session) Close() error { + err := sess.sessp.Close() + return err +} + // GeolocateResults contains the results of session.Geolocate. type GeolocateResults struct { // ASN is the autonomous system number.