Beispiel #1
0
 internal DomainContext( PddApi api, string domain ) : base(api, domain) {
     var rawContext = Api.Raw.Domain(DomainName);
     Deputy = new DeputyMethods( rawContext.Deputy );
     Dns = new DnsMethods( rawContext.Dns );
     Dkim = new DkimMethods( rawContext.Dkim );
     Domain = new DomainMethods( rawContext.Domain );
     Import = new ImportMethods( rawContext.Import );
     MailList = new MailListMethods( rawContext.MailList );
     Mail = new MailMethods( rawContext.Mail );
 }
Beispiel #2
0
        // Get a host by name synchronously.
        public static IPHostEntry GetHostByName(String hostName)
        {
            if (hostName == null)
            {
                throw new ArgumentNullException("hostname");
            }
            String h_name;

            String [] h_aliases;
            long []   h_addr_list;

            if (!DnsMethods.InternalGetHostByName(hostName, out h_name,
                                                  out h_aliases, out h_addr_list))
            {
                throw new SocketException();                         // Hm...
            }
            return(ToIPHostEntry(h_name, h_aliases, h_addr_list));
        }
Beispiel #3
0
        public static IPHostEntry GetHostByAddress(IPAddress address)
        {
            if (address == null)
            {
                throw new ArgumentNullException("address");
            }
            String h_name;

            String [] h_aliases;
            long []   h_addr_list;

            if (!DnsMethods.InternalGetHostByAddr(address.Address, out h_name,
                                                  out h_aliases, out h_addr_list))
            {
                throw new SocketException();                         // Hm...
            }
            return(ToIPHostEntry(h_name, h_aliases, h_addr_list));
        }
Beispiel #4
0
        protected override void BeginProcessing()
        {
            try
            {
                if (this.ParameterSetName.StartsWith(_GRID))
                {
                    if (this.Version.Equals("LATEST"))
                    {
                        using (HttpClient Client = CommandHelpers.BuildHttpClient(this.GridMaster, "1.0", this.Credential.UserName, this.Credential.Password, TimeSpan.FromSeconds(Timeout)).Result)
                        {
                            WriteVerbose("Getting supported versions.");

                            HttpResponseMessage Response = Client.GetAsync("?_schema").Result;

                            WriteVerbose(Response.RequestMessage.RequestUri.ToString());

                            if (Response.IsSuccessStatusCode)
                            {
                                string Content = Response.Content.ReadAsStringAsync().Result;

                                WriteVerbose($"Response {Content}");

                                dynamic Obj = JsonConvert.DeserializeObject(Content);
                                IEnumerable <string> Versions = Obj.supported_versions;

                                WriteVerbose("Got versions");

                                Versions = Versions.Select(x => { return(new Version(x)); }).OrderByDescending(x => x).Select(x => { return(x.ToString()); });

                                WriteVerbose("Sorted versions");
                                this.Version = Versions.First();
                                WriteVerbose($"Latest supported version is {this.Version}");
                            }
                            else
                            {
                                WriteVerbose("Failed to get schema, reverting to using version 2.0");
                                this.Version = "2.0";
                            }
                        }
                    }

                    this._IBX = new DnsMethods(this.GridMaster, this.Version, this.Credential.UserName, this.Credential.Password, TimeSpan.FromSeconds(Timeout));
                }
                else if (this.ParameterSetName.StartsWith(_SESSION))
                {
                    this._IBX = new DnsMethods(this.Session, TimeSpan.FromSeconds(Timeout));
                }
                else if (this.ParameterSetName.StartsWith(_ENTERED_SESSION))
                {
                    this._IBX = new DnsMethods(TimeSpan.FromSeconds(Timeout));
                }
                else
                {
                    this.ThrowTerminatingError(new ErrorRecord(new PSArgumentException($"Could not identify parameter set from {this.ParameterSetName}"), "PSArgumentException", ErrorCategory.InvalidArgument, this));
                }
            }
            catch (AggregateException ae)
            {
                PSCommon.WriteExceptions(ae, this.Host);
                this.ThrowTerminatingError(new ErrorRecord(ae.InnerException, ae.InnerException.GetType().FullName, ErrorCategory.NotSpecified, this));
            }
            catch (Exception e)
            {
                PSCommon.WriteExceptions(e, this.Host);
                this.ThrowTerminatingError(new ErrorRecord(e, e.GetType().FullName, ErrorCategory.NotSpecified, this));
            }
        }
Beispiel #5
0
 // Get the host name of the local machine.
 public static String GetHostName()
 {
     return(DnsMethods.InternalGetHostName());
 }