/** * @see org.apache.james.protocols.smtp.DNSService#getLocalHost() */ public InetAddress getLocalHost() throws UnknownHostException { return dns.getLocalHost(); }
private String getRemoteHost() { try { return dns.getLocalHost().getHostName(); } catch (UnknownHostException e) { return "localhost"; } }
private String getRemoteAddr() { try { return dns.getLocalHost().getHostAddress(); } catch (UnknownHostException e) { return LOCALHOST; } }
private void appendReportingMTA(StringBuffer buffer) { try { buffer.append("Reporting-MTA: dns; " + dns.getHostName(dns.getLocalHost())) .append(LINE_BREAK); } catch (Exception e) { LOGGER.error("Sending DSN without required Reporting-MTA Address", e); } }
private ImmutableList<Domain> detectDomains() { if (autoDetect) { String hostName; try { hostName = dns.getHostName(dns.getLocalHost()); } catch (UnknownHostException ue) { hostName = "localhost"; } LOGGER.info("Local host is: {}", hostName); if (hostName != null && !hostName.equals("localhost")) { return ImmutableList.of(Domain.of(hostName)); } } return ImmutableList.of(); }
public void setRemoteAddr() { try { mail.setRemoteAddr(dns.getLocalHost().getHostAddress()); } catch (UnknownHostException e) { mail.setRemoteAddr(LOCAHOST); } }
public void setRemoteHost() { try { mail.setRemoteHost(dns.getLocalHost().getHostName()); } catch (UnknownHostException e) { mail.setRemoteHost("localhost"); } }
@Before public void setUp() throws Exception { DNSService dnsService = mock(DNSService.class); bounce = new Bounce(dnsService); fakeMailContext = FakeMailContext.defaultContext(); when(dnsService.getLocalHost()).thenThrow(new UnknownHostException()); }
@Test public void containsDomainShouldReturnDetectedIp() throws Exception { String detected = "detected.tld"; String detectedIp = "148.25.32.1"; when(dnsService.getLocalHost()).thenReturn(InetAddress.getByName("127.0.0.1")); when(dnsService.getHostName(any(InetAddress.class))).thenReturn(detected); InetAddress detectedAddress = mock(InetAddress.class); when(detectedAddress.getHostAddress()).thenReturn(detectedIp); when(dnsService.getAllByName(detected)).thenReturn(ImmutableList.of(detectedAddress)); assertThat(domainList.containsDomain(Domain.of(detectedIp))).isTrue(); }
@BeforeEach void setUp() throws Exception { DNSService dnsService = mock(DNSService.class); when(dnsService.getHostName(any())).thenReturn("localhost"); when(dnsService.getLocalHost()).thenReturn(InetAddress.getByName("localhost")); MemoryDomainList domainList = new MemoryDomainList(dnsService); domainList.setAutoDetectIP(false); createServer(domainList); }
@Before public void setUp() throws Exception { DNSService dnsService = mock(DNSService.class); dsnBounce = new DSNBounce(dnsService, DateFormats.getRFC822FormatForTimeZone(TimeZone.getTimeZone("UTC"))); fakeMailContext = FakeMailContext.defaultContext(); InetAddress localHost = InetAddress.getLocalHost(); when(dnsService.getLocalHost()) .thenReturn(localHost); when(dnsService.getHostName(localHost)) .thenReturn("myhost"); }
@Test public void getDomainsShouldContainDetectedDomainsAndIps() throws Exception { domainList.configure(DomainListConfiguration.builder() .autoDetect(true) .autoDetectIp(true)); String detected = "detected.tld"; String detectedIp = "148.25.32.1"; when(dnsService.getLocalHost()).thenReturn(InetAddress.getByName("127.0.0.1")); when(dnsService.getHostName(any(InetAddress.class))).thenReturn(detected); InetAddress detectedAddress = mock(InetAddress.class); when(detectedAddress.getHostAddress()).thenReturn(detectedIp); when(dnsService.getAllByName(detected)).thenReturn(ImmutableList.of(detectedAddress)); assertThat(domainList.getDomains()).contains(Domain.of(detected), Domain.of(detectedIp)); }
@Before public void setUp() throws Exception { DNSService dnsService = mock(DNSService.class); resend = new Resend(dnsService); fakeMailContext = FakeMailContext.builder() .postmaster(new MailAddress("postmaster@james.org")) .build(); when(dnsService.getLocalHost()).thenThrow(new UnknownHostException()); }
@Test public void containsDomainShouldReturnDetectedDomains() throws Exception { domainList.configure(DomainListConfiguration.builder() .autoDetect(true) .autoDetectIp(false)); String detected = "detected.tld"; when(dnsService.getLocalHost()).thenReturn(InetAddress.getByName("127.0.0.1")); when(dnsService.getHostName(any(InetAddress.class))).thenReturn(detected); assertThat(domainList.containsDomain(Domain.of(detected))).isTrue(); }
@Before public void setUp() throws Exception { DNSService dnsService = mock(DNSService.class); notifyPostmaster = new NotifyPostmaster(dnsService); postmaster = new MailAddress("postmaster@james.org"); fakeMailContext = FakeMailContext.builder() .postmaster(postmaster) .build(); when(dnsService.getLocalHost()).thenThrow(new UnknownHostException()); }
@Before public void setUp() throws Exception { DNSService dnsService = mock(DNSService.class); forward = new Forward(dnsService); postmaster = new MailAddress("postmaster@james.org"); fakeMailContext = FakeMailContext.builder() .postmaster(postmaster) .build(); when(dnsService.getLocalHost()).thenThrow(new UnknownHostException()); }
@Before public void setUp() throws Exception { DNSService dnsService = mock(DNSService.class); notifySender = new NotifySender(dnsService); fakeMailContext = FakeMailContext.builder() .postmaster(new MailAddress("postmaster@james.org")) .build(); when(dnsService.getLocalHost()).thenThrow(new UnknownHostException()); }
@Before public void setUp() throws Exception { DNSService dnsService = mock(DNSService.class); redirect = new Redirect(dnsService); postmaster = new MailAddress("postmaster@james.org"); fakeMailContext = FakeMailContext.builder() .postmaster(postmaster) .build(); when(dnsService.getLocalHost()).thenThrow(new UnknownHostException()); }
@Test public void getDomainsShouldContainDetectedDomains() throws Exception { domainList.configure(DomainListConfiguration.builder() .autoDetect(true) .autoDetectIp(false)); String detected = "detected.tld"; when(dnsService.getLocalHost()).thenReturn(InetAddress.getByName("127.0.0.1")); when(dnsService.getHostName(any(InetAddress.class))).thenReturn(detected); assertThat(domainList.getDomains()).contains(Domain.of(detected)); }
@BeforeEach void setup() throws Exception { DNSService dnsService = mock(DNSService.class); Mockito.when(dnsService.getHostName(any())).thenReturn("localhost"); Mockito.when(dnsService.getLocalHost()).thenReturn(InetAddress.getByName("localhost")); MemoryDomainList domainList = new MemoryDomainList(dnsService); domainList.setAutoDetectIP(false); domainList.setAutoDetect(false); domainList.addDomain(SENDER_DOMAIN); domainList.addDomain(SENDER_DOMAIN_2); dlpStore = new EventSourcingDLPConfigurationStore(new InMemoryEventStore()); createServer(dlpStore, domainList); }