-
Notifications
You must be signed in to change notification settings - Fork 49
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
mobileproxy clib #226
Draft
daniellacosse
wants to merge
17
commits into
main
Choose a base branch
from
daniellacosse/clib/init
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
mobileproxy clib #226
Changes from 2 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
2eaa36b
init commit
daniellacosse 624a90f
handlers
daniellacosse f323528
Update x/mobileproxy/clib/clib.go
daniellacosse 931027f
Update x/mobileproxy/clib/clib.go
daniellacosse 53ed6c2
Update x/mobileproxy/clib/clib.go
daniellacosse 81fc937
Update x/mobileproxy/clib/clib.go
daniellacosse c7989b1
where is the output?
daniellacosse f617762
add main
daniellacosse 042d9a3
properly reference handle
daniellacosse 6b16192
update changes and move to examples
daniellacosse 0d3f1ee
rename to main
daniellacosse cde8a2b
draft demo program
daniellacosse 6d396e0
getting close - pointer is unpinned
daniellacosse 68f183f
uintptr attempt
daniellacosse 13220da
strongly typed StreamDialer and Proxy in C using uintptr_t
jyyi1 4b984e7
update demo application
jyyi1 ba9cd7e
Merge branch 'main' into daniellacosse/clib/init
jyyi1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package clib | ||
|
||
// #include <stdlib.h> | ||
import ( | ||
"C" | ||
"runtime/cgo" | ||
|
||
"github.com/Jigsaw-Code/outline-sdk/x/mobileproxy" | ||
) | ||
|
||
type ProxyHandle = cgo.Handle | ||
type StreamDialerHandle = cgo.Handle | ||
|
||
//export NewStreamDialerFromConfig | ||
func NewStreamDialerFromConfig(config *C.char) StreamDialerHandle { | ||
daniellacosse marked this conversation as resolved.
Show resolved
Hide resolved
|
||
streamDialer, err := mobileproxy.NewStreamDialerFromConfig(C.GoString(config)) | ||
|
||
if err != nil { | ||
// TODO: print something? | ||
return cgo.NewHandle(nil) | ||
} | ||
|
||
return cgo.NewHandle(streamDialer) | ||
} | ||
|
||
//export RunProxy | ||
func RunProxy(address *C.char, dialerHandle StreamDialerHandle) ProxyHandle { | ||
daniellacosse marked this conversation as resolved.
Show resolved
Hide resolved
|
||
dialer := dialerHandle.Value().(mobileproxy.StreamDialer) | ||
daniellacosse marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
proxy, err := mobileproxy.RunProxy(C.GoString(address), &dialer) | ||
|
||
if err != nil { | ||
// TODO: print something? | ||
return cgo.NewHandle(nil) | ||
daniellacosse marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
return cgo.NewHandle(proxy) | ||
daniellacosse marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
//export AddURLProxy | ||
func AddURLProxy(proxyHandle ProxyHandle, url *C.char) { | ||
proxy := proxyHandle.Value().(mobileproxy.Proxy) | ||
|
||
proxy.AddURLProxy(C.GoString(url)) | ||
} | ||
|
||
//export StopProxy | ||
func StopProxy(proxyHandle ProxyHandle, timeoutSeconds C.uint) { | ||
proxy := proxyHandle.Value().(mobileproxy.Proxy) | ||
|
||
proxy.Stop(timeoutSeconds) | ||
} | ||
|
||
//export DestroyStreamDialer | ||
func DestroyStreamDialer(dialer StreamDialerHandle) { | ||
dialer.Delete() | ||
} | ||
|
||
//export DestroyProxy | ||
func DestroyProxy(proxy ProxyHandle) { | ||
proxy.Delete() | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
We need to see this in action to be confident it works.
Please add a program that uses this library.
Some possibilities would be a c program, or a go program that calls this library via cgo.
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.
Okay, great! We're already at that stage I guess!
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.
In the interest of timing, maybe I can move this into experimental for now?
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 don't know what you mean with moving to experimental.
The binary can be in the examples folder, but we need it in order to know it works.
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.
Sorry, I meant examples! Okay, sure, I'll commit the binary to examples, and we can go from there
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.
If you'd like to use Abseil for flags, etc: https://abseil.io/docs/cpp/quickstart
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'm not saying we shouldn't have a program! Just that given timing, I'd like to get the library in so a test program can be written around it, rather than it just hanging in the air. Do you feel a program blocks this PR @jyyi1 or can it be added in a follow-up?
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 would like to have this code checked in only when we have proof it works. I see no harm in keeping it in a branch if we can't produce a program that can use it.
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.
"Can't" is a strong word, we certainly can, but maybe not by the end of the week since I'm learning C as we go here: I'll see what I can do.
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 have started the program based on @jyyi1's initial draft and will review that with him today.