-
Notifications
You must be signed in to change notification settings - Fork 14
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
iOS Ping functionality #602
Conversation
Testing it out, when "Cogeco Peer 1" is selected from the Ping Us menu, the node for "Zenedge LLC" is shown. I'm not sure this is correct, since if you search for Cogeco Peer 1 in the Search window there are multiple ASNs that correspond to that name. I would assume the Ping for one of those would be what we would want to show? Perhaps it is the case here that the URL |
Yeah I've seen that hostname resolve to
The current ping behaviour is consistent with what a user would see if they looked up the |
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.
Mostly looks reasonable to me, couple of very minor comments, but they are all pretty judgment-call / optional sort of things, so I don't think merge should be blocked on any of them.
Library/SCPingUtility.swift
Outdated
@objc var delegate: SCPingUtilityDelegate? | ||
|
||
@objc public var packetRecords: [SCPacketRecord] { | ||
let records = icmpUtility.packetRecords as! [SCPacketRecord] |
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.
Force cast here seems like it shouldn't be necessary, as the ObjC code is annotated with the right type. Was it maybe from before the annotation as added and never got removed?
Alternatively, is it maybe complaining because it things it might be nullable, and there needs to be a nullable annotation on that as well?
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.
Yeah I was confused by this too. For some reason the generic type isn't bridging to Swift. The interface swift sees is:
var packetRecords: NSMutableArray! { get }
A bit of google searching led me to this Swift bug: Swift does not honor NSMutableArray generics from objective-c classes. I could try the workaround of changing the public interface to NSArray<SCPacketRecord *>
as long as nothing else depends on modifying that array.
@@ -109,22 +109,19 @@ public class CreditsViewController: UIViewController, UIWebViewDelegate { | |||
doneButton.layer.cornerRadius = doneButton.frame.size.height / 2 | |||
view.addSubview(doneButton) | |||
|
|||
// iPhoneX support | |||
if #available(iOS 11.0, *) { |
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 assume this availbility is going away because the minimum platform is iOS 11 now, It looks like there is one other one that is still there, should maybe remove that as well?
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.
👍
It looks like there is some inconsistency with the target and project ios deployment target settings so I'll try to fix that too.
backgroundImageView.leftAnchor.constraint(equalTo: view.leftAnchor).isActive = true | ||
backgroundImageView.topAnchor.constraint(equalTo: view.topAnchor).isActive = true | ||
backgroundImageView.rightAnchor.constraint(equalTo: view.rightAnchor).isActive = true | ||
backgroundImageView.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true |
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.
Not sure how important it is, but it looks like there are at least 3 places (maybe more not included in this change) that we do this "turn of autoresizing mask and then pin to the same edges of the superview" thing. Might be worth having a utility function or category to do this as a one liner?
Not sure if it's worth it though, 3 copy-and-pastes is right no the edge of where I'd say it's a no-brainer to have a utility function, so if that's all there is maybe it's not actually worth it.
Other option would be to wait until NEXT time we have to do something like this, and just add SnapKit.
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.
Yeah I would like to bring in Snapkit but I figured we should sort out all the other out of date dependencies (#596) before bringing in a new one. If you feel strongly that this boilerplate-y autolayout code should be improved now, then I can bring it in sooner. Developing our own helpers would be kind of fun but I feel like I'd just end up reimplementing Snapkit's nice interface:
box.snp.makeConstraints { (make) -> Void in
make.edges.equalTo(superview)
}
😍
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.
Looks reasonable to me, it's a bit of a shame that it gets so gnarly to expose a reasonable interface for the packet records to Swift, but I think what you've got is a reasonable work around, and if we are going to have annoying warts better to have them in the ObjC code then the Swift code.
🚀
Fixes #463
This adds a rudimentary
SCPingUtility
that is triggered via the (i) menu -> Ping Cogeco Peer 1. Peer 1 is supposed to supply us with some hostnames to ping but in the meantime I've added three for test purposes (note:cogecopeer1.com
does not respond to pings):When an entry is selected by the user, we do some lookups: hostname -> IP -> ANS. If the ANS is found and we know about it, we select the node on the map and automatically trigger the ping to the IP found during the lookup process.
@apike I don't know how soon we'll have the peer1 hostnames. If it might be a while, we could rename the menu item from "Ping Cogeco Peer1" to "Ping Popular Hosts" or something else and add a few more hostnames that we choose.