Skip to content
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

Transport Tester GUI App: add support for generic transport, send report, UI polish #170

Open
wants to merge 26 commits into
base: main
Choose a base branch
from

Conversation

amircybersec
Copy link
Contributor

@amircybersec amircybersec commented Jan 22, 2024

This PR replaces PR #137; since I had to rebase and refactor the PR #137 that it got a bit out of hand and decided to cherry pick commits into a clean branch off main. Here's is the summary of changes made to the Transport Tester GUI App:

CHANGELOG:

  • Add a new optional report collector URL field to the GUI (shared front-end)
  • Submit reports to a remote destination using report package (shared backend). One simple approach to set up a remote collector using Google Spreadsheet is discussed here.
  • Add support for existing SDK transports and wrapping (e.g. split, socks5, tls, ss, etc)
  • Redact UserInfo from transports in reports, e.g.: ss://REDACTED@104.238.100.16:65496
  • Include transport specific setup errors (e.g. split not supported over udp) in response error field
  • Display error message on the GUI (front-end)
  • Renamed app to Transport Tester
  • Add Powered By Outline logo
  • Add popover to show information for each field
ios android macOS

@amircybersec amircybersec marked this pull request as ready for review January 22, 2024 22:02
@amircybersec
Copy link
Contributor Author

amircybersec commented Jan 22, 2024

@daniellacosse could you please review this PR? I applied the comments on the previous PR which is now closed over to this one; I had to refactor and rebase the previous PR and it got a bit messy and I decided to start off on a new branch and cherrypick the changes over to this one.

BTW, I tested the app on MacOS, iOS and Android and everything checked out in the overall functionality.

Popover on Android emulator breaks before WenView is upgraded which should not be a problem on physical devices that have already logged into Google Play services. I guess Google is going to include a more updated version of WebView as default soon which automatically fixes this issue on Android emulator.

Copy link
Contributor

@daniellacosse daniellacosse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should be using slots instead of unsafeHTML https://lit.dev/docs/frameworks/react/#using-slots


One simple approach to set up a remote collector using Google Spreadsheet is discussed [here](https://github.com/amircybersec/report-collector).

The following are app screenshots on Android and iOS. The app can also run on Linux, MacOs and Windows.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: MacOS

@@ -4,6 +4,22 @@

This is a simple cross-platform app to test connectivity to Outline servers, using the Outline SDK. It is built with [Wails](https://wails.app/) and [Capacitor](https://capacitorjs.com/).

## Usage

This is an example application that accepts a transport configuration (for example `shadowsocks`) as defined [here](https://pkg.go.dev/github.com/Jigsaw-Code/outline-sdk/x/config) and performs DNS resolution over the specified transport using provided list of resolvers and domain name.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line slightly conflicts with the line above. I might merge the below line with the above and rename this section.

type ConnectivityTestError struct {
// TODO: add Shadowsocks/Transport error
Op string `json:"operation"`
Op string `json:"op,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm personally not a fan of abbreviations? Maybe we change Op to Operation instead

}
retryCollector := &report.RetryCollector{
Collector: remoteCollector,
MaxRetry: 3,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we pass in a config object with these values?

@@ -0,0 +1,50 @@
import { css, html, LitElement, nothing } from "lit";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel that the use of separate component here is a bit overkill. Why not <img src='./outline_logo.svg' /> and style that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@daniellacosse that was the first approach I tried but I could not figure out a way to serve static content as the app could not find ./outline_logo.svg file location. Do you have any tips on serving static content in Index.ts?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may require some doing. This is how to serve static assets in Wails: https://wails.io/docs/guides/dynamic-assets/ And I think Capacitor mounts a webdir: https://capacitorjs.com/docs/config

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason I opted for creating a custom Lit element for the logo was to avoid framework specific setup. The current approach only works for SVG or text-based assets though. It seems like we don't need to do that for CSS assets here since they are encapsulated in custom Lite elements in the code.

For PNG/JPG/etc images, we need to offer a way to serve static assets though.

If you agree, I can add this as TODO item as technical debt / improvement to README and do it via a separate PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, okay with a TODO.

<div @click="${this.showPopover}" popovertarget="my-popover" popovertargetaction="show">ℹ️</div>
<div popover="auto" class="popup" id="my-popover">
<span @click="${this.closePopover}" class="close-button" popovertargetaction="hide">&times;</span>
${unsafeHTML(this.popupText)}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should definitely be using slots instead of unsafeHTML https://lit.dev/docs/frameworks/react/#using-slots

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was able to use slots to show the popover message but I am not able to display HTML formatted text (HTML tags) to display correctly using slots. For example, currently I am using <strong> and <a> url tags in one of the popovers:

<info-popup popupText="Options include <strong>ss://</strong>, <strong>split://</strong>,
      <strong>tls://</strong>, <strong>socks5://</strong>, and/or a combination of them.
      For examples and more information check out the documentation
      <a href='https://pkg.go.dev/github.com/Jigsaw-Code/outline-sdk/x/config'> here</a>.">
</info-popup>

which looks like this:

Screenshot 2024-01-25 at 1 44 51 PM

If I use slot, the message would look like this:

<info-popup> 
  <p> Options include <strong>ss://</strong>, <strong>split://</strong>,
  <strong>tls://</strong>, <strong>socks5://</strong>, and/or a combination of them.
  For examples and more information check out the documentation
  <a href='https://pkg.go.dev/github.com/Jigsaw-Code/outline-sdk/x/config'> here</a>.
  </p>
</info-popup>
Screenshot 2024-01-25 at 1 54 03 PM

The main reason I used unsafeHTML was to be able to render HTML formatted text. Even though I am rendering static text and unsafeHTML does not pose a security issue, I agree it is not a clean solution here.

I can ditch HTML formatting altogether here but if you have any suggestions to support markup or HTML tags in the popover text, please do let me know.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you show me how you implemented the slot? Here's an example I did recently that works: Jigsaw-Code/outline-server#1482

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The slot works but the HTML formatting of the text is ignored...

This is the change in popover_info.ts file:

  render() {
    return html`
    <div @click="${this.showPopover}" popovertarget="my-popover" popovertargetaction="show">ℹ️</div>
    <div popover="auto" class="popup" id="my-popover">
      <span @click="${this.closePopover}" class="close-button" popovertargetaction="hide">&times;</span>
      <slot></slot>
    </div>
    `;
  }

Copy link
Contributor

@daniellacosse daniellacosse Jan 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think maybe the CSS reset is taking effect when you use the <slot></slot>, which is intentional. There's no telling how different browsers will style things, so to ensure consistency we strip the default styles and re-implement them.


static styles = css`
.popup {
top: -50%; /* Position above the element */
Copy link
Contributor

@daniellacosse daniellacosse Jan 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note that I'm saving most of my HTML/CSS comments for last

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants