[ https://issues.apache.org/jira/browse/NETBEANS-96?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16243760#comment-16243760 ]
ASF GitHub Bot commented on NETBEANS-96: ---------------------------------------- lbruun commented on a change in pull request #161: [NETBEANS-96] New PAC Script evaluation environment URL: https://github.com/apache/incubator-netbeans/pull/161#discussion_r149642386 ########## File path: core.network/src/org/netbeans/core/network/utils/HostnameUtils.java ########## @@ -0,0 +1,72 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.netbeans.core.network.utils; + +import com.sun.jna.Platform; + +/** + * Utility functions for finding the local computer's name. + * + * + * @author lbruun + */ +public class HostnameUtils { + + private HostnameUtils() {} + + + /** + * Gets the name which is likely to be the local host's primary + * name on the network. + * + * <p> + * IMPLEMENTATION: + * <p> + * <ul> + * <li>On Unix-like OSes (incl Mac OS X) this is the value as returned from + * the {@code gethostname()} function from the standard C Library. </li> + * <li>On Windows it is the value as returned from the + * {@code gethostname()} function from {@code Ws2_32} library. + * (without domain name). Note that this Windows function will do a + * name service lookup and the method is therefore potentially blocking, + * although it is more than likely that Windows has cached this result + * on computer startup in its DNS Client Cache and therefore the + * result will be returned very fast.</li> + * </ul> + * + * @return host name + * @throws NativeException if there was an error executing the + * system call. + */ + public static String getNetworkHostname() throws NativeException { Review comment: Well, this is partly due to history. If I remember correctly, I used to use different functions on MacOSX and Linux. But through trials and tests I finally settled on using the same C lib function on everything but Windows. I may revert that. The `hname` packages exist mainly as a way to get the host's _kernel name_, so that we can use that in an insane ride to find the host's own IP address as it is generally known on the network. This functionality is mandated for PAC evaluator. But when I started on the hname package, I thought of it as a general purpose package for everything related to the host's naming. For example, I wanted to add methods for getting the host's _display name_, e.g. "Joey's Laptop" and this is done very differently between OSes. This is another reason for the sub-packages per OS. I don't know if I'll ever get around to adding that. Right now the focus was on getting a working PAC evaluator as the existing one is broken. And frankly the host's display name has little usage except for use in About box and things like that. :-) I would like to keep the subpackages and the delegation for now even if it is a lot of ceremony for nothing. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > New PAC Script evaluator > ------------------------ > > Key: NETBEANS-96 > URL: https://issues.apache.org/jira/browse/NETBEANS-96 > Project: NetBeans > Issue Type: Improvement > Reporter: lbruun > Labels: pull-request-available > > The current [PAC script|https://en.wikipedia.org/wiki/Proxy_auto-config] > evaluator (in {{core.network}}) was developed pre-Nashorn and has a few > problems: > * It simply fails with Nashorn - but not with Rhino - if the downloaded > script uses {{isInNet()}}. This was reported in [Bug > 245116|https://netbeans.org/bugzilla/show_bug.cgi?id=245116]. It fails > silently in this case and defaults to no proxy. The user will never know the > reason - not even by looking in the message log - that there was an error. > * It doesn't implement two mandatory JavaScript helper methods, > {{dnsResolve()}} and {{myIpAddress()}}. This is a known issue. This causes > many PAC scripts to silently fail. > * It doesn't implement Microsoft's IPv6-aware additions to the PAC standard. > This is a problem in MS shops because they will have designed their PAC > script to be compatible with MS IE and MS Edge (which unsurprisingly support > these functions .. as do Chrome). > * It uses a small JavaScript helper, {{nsProxyAutoConfig.js}}, which uses a > license which is not compatible with Apache. This is described in NETBEANS-4. > * Isn't executing the downloaded PAC script in a sandboxed environment. (The > PAC script should be treated as hostile because the download may have been > spoofed. Browsers indeed treat the PAC script as hostile and so should > NetBeans). > Pull Request with a new implementation is on its way. -- This message was sent by Atlassian JIRA (v6.4.14#64029)