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

Add TURN server to personal settings. #84

Merged
merged 6 commits into from
Nov 21, 2016
Merged

Conversation

fancycode
Copy link
Member

This implements the second part of #2 to add TURN support. For now each user
has to have an account on the TURN server. Support for shared credentials will
be added in a separate PR.

@nickvergessen @LukasReschke

$uid = \OC::$server->getUserSession()->getUser()->getUID();

$settings = Util::getTurnSettings($config, $uid);
//server":"1","username":"2","password":"3","protocols
Copy link
Member Author

Choose a reason for hiding this comment

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

Whoops, some debugging leftover - will remove together with other feedback you might have.

Copy link
Member

@LukasReschke LukasReschke left a comment

Choose a reason for hiding this comment

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

Looks good. Some remarks below.

I'm not entirely sure if it is really required that users can configure their own TURN server as well. But well 🙈

);
}

}
Copy link
Member

Choose a reason for hiding this comment

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

All hail to unit tests 😉 – At least as it is a new file. :-)

Copy link
Member Author

Choose a reason for hiding this comment

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

Can you recommend an existing unittest for a controller I should use as starting point?

Copy link
Member

@LukasReschke LukasReschke Nov 15, 2016

Choose a reason for hiding this comment

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

Absolutely. Gimme some mins ;-)

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Added a test in b6b263a


use OCA\Spreed\Util;

\OC_Util::checkLoggedIn();
Copy link
Member

Choose a reason for hiding this comment

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

Not required anymore since ownCloud 8 or so :-)

$settings = Util::getTurnSettings($config, $uid);
//server":"1","username":"2","password":"3","protocols
$tmpl->assign('turnSettings', $settings);
return $tmpl->fetchPage();
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, will update.

@@ -29,4 +29,12 @@ public static function getStunServer(IConfig $config) {
return $config->getAppValue('spreed', 'stun_server', 'stun.l.google.com:19302');
}

public static function getTurnSettings(IConfig $config, string $uid) {
Copy link
Member

Choose a reason for hiding this comment

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

Seems kinda strange to always have to inject IConfig and so on. Maybe make it non-static? :-)

Copy link
Member Author

Choose a reason for hiding this comment

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

I will create a separate PR to change this, also for the existing code.

parent::__construct($appName, $request);
$this->l10n = $l10n;
$this->config = $config;
$this->user = $userSession && $userSession->isLoggedIn() ? $userSession->getUser() : false;
Copy link
Member

Choose a reason for hiding this comment

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

If you just want the UID just use $UserId and it will automatically inject the current user id. It's like the appname thingy :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Well well, so much to learn... ;-)

parent::__construct('spreed');
$container = $this->getContainer();

$container->registerAlias('PersonalSettingsController', PersonalSettingsController::class);
Copy link
Member

Choose a reason for hiding this comment

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

this should not be needed

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, if I remove it, loading the settings fails with this error (from nextcloud.log):

"Exception: {\"Exception\":\"OCP\\\\AppFramework\\\\QueryException\",\"Message\":\"Could not resolve PersonalSettingsController! Class PersonalSettingsController does not exist\",\"Code\":0,\"Trace\":\"#0 \\\/srv\\\/www\\\/lib\\\/private\\\/AppFramework\\\/Utility\\\/SimpleContainer.php(117): OC\\\\AppFramework\\\\Utility\\\\SimpleContainer->resolve('PersonalSetting...')\\n#1 \\\/srv\\\/www\\\/lib\\\/private\\\/AppFramework\\\/DependencyInjection\\\/DIContainer.php(540): OC\\\\AppFramework\\\\Utility\\\\SimpleContainer->query('PersonalSetting...')\\n#2 \\\/srv\\\/www\\\/apps\\\/spreed\\\/personal.php(24): OC\\\\AppFramework\\\\DependencyInjection\\\\DIContainer->query('PersonalSetting...')\\n#3 \\\/srv\\\/www\\\/lib\\\/private\\\/legacy\\\/app.php(757): include('\\\/srv\\\/www\\\/apps\\\/s...')\\n#4 \\\/srv\\\/www\\\/settings\\\/personal.php(184): OC_App::getForms('personal')\\n#5 \\\/srv\\\/www\\\/lib\\\/private\\\/Route\\\/Route.php(155) : runtime-created function(1): require_once('\\\/srv\\\/www\\\/settin...')\\n#6 [internal function]: __lambda_func()\\n#7 \\\/srv\\\/www\\\/lib\\\/private\\\/Route\\\/Router.php(298): call_user_func('\\\\x00lambda_603', Array)\\n#8 \\\/srv\\\/www\\\/lib\\\/base.php(1000): OC\\\\Route\\\\Router->match('\\\/settings\\\/perso...')\\n#9 \\\/srv\\\/www\\\/index.php(40): OC::handleRequest()\\n#10 {main}\",\"File\":\"\\\/srv\\\/www\\\/lib\\\/private\\\/AppFramework\\\/Utility\\\/SimpleContainer.php\",\"Line\":102}"

@fancycode fancycode force-pushed the personal_turn_settings branch from 56094da to 2a3229d Compare November 15, 2016 09:02
@MorrisJobke MorrisJobke force-pushed the personal_turn_settings branch from fe97298 to 45e0267 Compare November 15, 2016 16:35
@MorrisJobke
Copy link
Member

Just FYI: I rebased this ;)

@@ -47,4 +47,4 @@

\OCP\Util::connectHook('OC_User', 'post_deleteUser', \OCA\Spreed\Util::class, 'deleteUser');

OC_App::registerPersonal('spreed', 'personal');
\OCP\App::registerPersonal('spreed', 'personal');
Copy link
Member

Choose a reason for hiding this comment

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

@fancycode This fixes the app:check-code CI check ;)

@MorrisJobke
Copy link
Member

I tested this and it works 👍

Code looks good :)

@MorrisJobke MorrisJobke added this to the 1.0.0 milestone Nov 15, 2016
@jancborchardt
Copy link
Member

I also fixed the naming to be »Spreed video calls« everywhere (appname and settings headers for both personal and admin settings) because we were calling it different names. :)

@fancycode fancycode force-pushed the personal_turn_settings branch from 214b03e to d02b4a4 Compare November 16, 2016 07:59
@fancycode
Copy link
Member Author

Squashed a couple of commits and added Signed-off-by markers.

@LukasReschke please review

@codecov-io
Copy link

Current coverage is 10.92% (diff: 46.15%)

Merging #84 into master will increase coverage by 3.98%

@@            master        #84   diff @@
=========================================
  Files           11         13     +2   
  Lines          577        641    +64   
  Methods         39         44     +5   
  Messages         0          0          
  Branches         0          0          
=========================================
+ Hits            40         70    +30   
- Misses         537        571    +34   
  Partials         0          0          

Powered by Codecov. Last update 7a743fe...d02b4a4

@jancborchardt
Copy link
Member

So I know you @MorrisJobke @fancycode talked about why this is in the personal settings. But it is a really strange UX to have it there. That would mean every single user would have to specify it, and many even technical people probably never heard about it.

So, let’s move it to the Admin settings please? ;)

@fancycode
Copy link
Member Author

Well, the settings as-is (i.e. username and password) is per user, so the personal settings is the right place.

For the Admin area we should have an additional setting to configure a shared secret to be used, but that requires some application-level code to generate TURN credentials dynamically for the different participants. I'm planning to add this in a separate PR.

IMHO both settings make sense depending on the use case.

@jancborchardt
Copy link
Member

@LukasReschke your call please :)

(UX-wise I’d prefer if we start with it being in Admin settings first, and only then add per-user settings. Cause then they can edit based on the configured TURN server.)

@LukasReschke
Copy link
Member

Agreeing with @jancborchardt. User settings do look rather confusing. An instance-wide setting seems way more user-friendly.

For the Admin area we should have an additional setting to configure a shared secret to be used, but that requires some application-level code to generate TURN credentials dynamically for the different participants. I'm planning to add this in a separate PR.

Based on https://github.com/andyet/signalmaster/blob/e98d388a2107330948616661064cb329d2749314/sockets.js#L105-L124 which is the signalling server that we ported this should likely be done at

case 'stunservers':
$response = [];
$stunServer = Util::getStunServer($this->config);
if ($stunServer) {
array_push($response, [
'url' => 'stun:' . $stunServer,
]);
}
break;
.

@MorrisJobke
Copy link
Member

Cause then they can edit based on the configured TURN server.)

That's not how these are usually set up. Either the admin has one which creates the profiles for the users on demand or the users have a completely different one (also every user could have a different one very likely if they have one at all)

@MorrisJobke
Copy link
Member

I will rebase this one here to be able to merge it. Then I will look into the admin setting for the TURN server.

fancycode and others added 6 commits November 21, 2016 14:41
This implements the second part of #2 to add TURN support. For now each user
has to have an account on the TURN server. Support for shared credentials will
be added in a separate PR.

Signed-off-by: Joachim Bauch <bauch@struktur.de>
Signed-off-by: Joachim Bauch <bauch@struktur.de>
Signed-off-by: Joachim Bauch <bauch@struktur.de>
Signed-off-by: Joachim Bauch <bauch@struktur.de>
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Signed-off-by: Jan-Christoph Borchardt <hey@jancborchardt.net>
@MorrisJobke MorrisJobke force-pushed the personal_turn_settings branch from d02b4a4 to df3f436 Compare November 21, 2016 13:41
@fancycode
Copy link
Member Author

For the admin setting, I would recommend to use the shared-secret mode and generate username/password similar to what we are doing in spreed-webrtc:
https://github.com/strukturag/spreed-webrtc/blob/e18dd5c93382f4e15fcd97e921a680cd2494622f/go/channelling/hub.go#L94

@MorrisJobke
Copy link
Member

For the admin setting, I would recommend to use the shared-secret mode and generate username/password similar to what we are doing in spreed-webrtc:

Yes. That was the plan :)

@fancycode
Copy link
Member Author

Great 👍

@MorrisJobke
Copy link
Member

Failing CI is also on master (eslint) I will fix this later.

@MorrisJobke
Copy link
Member

Talked with @LukasReschke and he is fine -> merge

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.

6 participants